ETH Price: $3,403.76 (+4.46%)

Contract

0x1480408655562b64CbcA6E677cE7E6f810Dcb682
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ExecWithSigsFacet

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
london EvmVersion, MIT license
File 1 of 19 : ExecWithSigsFacet.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {BFacetOwner} from "../facets/base/BFacetOwner.sol";
import {LibDiamond} from "../libraries/diamond/standard/LibDiamond.sol";
import {GelatoBytes} from "../libraries/GelatoBytes.sol";
import {ExecWithSigsBase} from "./base/ExecWithSigsBase.sol";
import {GelatoCallUtils} from "../libraries/GelatoCallUtils.sol";
import {
    _getBalance,
    _simulateAndRevert,
    _revert,
    _revertWithFee,
    _revertWithFeeAndIsFeeCollector
} from "../functions/Utils.sol";
import {
    ExecWithSigs,
    ExecWithSigsTrackFee,
    ExecWithSigsFeeCollector,
    ExecWithSigsRelayContext,
    Message,
    MessageTrackFee,
    MessageFeeCollector,
    MessageRelayContext
} from "../types/CallTypes.sol";
import {_isCheckerSigner} from "./storage/SignerStorage.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {
    _encodeRelayContext,
    _encodeFeeCollector
} from "@gelatonetwork/relay-context/contracts/functions/GelatoRelayUtils.sol";

contract ExecWithSigsFacet is ExecWithSigsBase, BFacetOwner {
    using GelatoCallUtils for address;
    using LibDiamond for address;

    //solhint-disable-next-line const-name-snakecase
    string public constant name = "ExecWithSigsFacet";
    //solhint-disable-next-line const-name-snakecase
    string public constant version = "1";

    address public immutable feeCollector;

    event LogExecWithSigsTrackFee(
        bytes32 correlationId,
        MessageTrackFee msg,
        address indexed executorSigner,
        address indexed checkerSigner,
        uint256 observedFee,
        uint256 estimatedGasUsed,
        address sender
    );

    event LogExecWithSigs(
        bytes32 correlationId,
        Message msg,
        address indexed executorSigner,
        address indexed checkerSigner,
        uint256 estimatedGasUsed,
        address sender
    );

    event LogExecWithSigsFeeCollector(
        bytes32 correlationId,
        MessageFeeCollector msg,
        address indexed executorSigner,
        address indexed checkerSigner,
        uint256 observedFee,
        uint256 estimatedGasUsed,
        address sender
    );

    event LogExecWithSigsRelayContext(
        bytes32 correlationId,
        MessageRelayContext msg,
        address indexed executorSigner,
        address indexed checkerSigner,
        uint256 observedFee,
        uint256 estimatedGasUsed,
        address sender
    );

    constructor(address _feeCollector) {
        feeCollector = _feeCollector;
    }

    // solhint-disable function-max-lines
    /// @param _call Execution payload packed into ExecWithSigsTrackFee struct
    /// @return estimatedGasUsed Estimated gas used using gas metering
    /// @return observedFee The fee transferred to the fee collector or diamond
    function execWithSigsTrackFee(
        ExecWithSigsTrackFee calldata _call
    ) external returns (uint256 estimatedGasUsed, uint256 observedFee) {
        uint256 startGas = gasleft();

        require(
            msg.sender == tx.origin,
            "ExecWithSigsFacet.execWithSigsTrackFee: only EOAs"
        );

        _requireSignerDeadline(
            _call.msg.deadline,
            "ExecWithSigsFacet.execWithSigsTrackFee._requireSignerDeadline:"
        );

        bytes32 digest = _getDigestTrackFee(_getDomainSeparator(), _call.msg);

        address executorSigner = _requireExecutorSignerSignature(
            digest,
            _call.executorSignerSig,
            "ExecWithSigsFacet.execWithSigsTrackFee._requireExecutorSignerSignature:"
        );

        address checkerSigner = _requireCheckerSignerSignature(
            digest,
            _call.checkerSignerSig,
            "ExecWithSigsFacet.execWithSigsTrackFee._requireCheckerSignerSignature:"
        );

        address feeRecipient = _call.msg.isFeeCollector
            ? feeCollector
            : address(this);

        {
            uint256 preFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeRecipient
            );

            // call forward
            _call.msg.service.revertingContractCall(
                _call.msg.data,
                "ExecWithSigsFacet.execWithSigsTrackFee:"
            );

            uint256 postFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeRecipient
            );

            observedFee = postFeeTokenBalance - preFeeTokenBalance;
        }

        estimatedGasUsed = startGas - gasleft();

        emit LogExecWithSigsTrackFee(
            _call.correlationId,
            _call.msg,
            executorSigner,
            checkerSigner,
            observedFee,
            estimatedGasUsed,
            msg.sender
        );
    }

    // solhint-disable function-max-lines
    /// @param _call Execution payload packed into ExecWithSigs struct
    /// @return estimatedGasUsed Estimated gas used using gas metering
    function execWithSigs(
        ExecWithSigs calldata _call
    ) external returns (uint256 estimatedGasUsed) {
        uint256 startGas = gasleft();

        require(
            msg.sender == tx.origin,
            "ExecWithSigsFacet.execWithSigs: only EOAs"
        );

        _requireSignerDeadline(
            _call.msg.deadline,
            "ExecWithSigsFacet.execWithSigs._requireSignerDeadline:"
        );

        bytes32 digest = _getDigest(_getDomainSeparator(), _call.msg);

        address executorSigner = _requireExecutorSignerSignature(
            digest,
            _call.executorSignerSig,
            "ExecWithSigsFacet.execWithSigs._requireExecutorSignerSignature:"
        );

        address checkerSigner = _requireCheckerSignerSignature(
            digest,
            _call.checkerSignerSig,
            "ExecWithSigsFacet.execWithSigs._requireCheckerSignerSignature:"
        );

        // call forward
        _call.msg.service.revertingContractCall(
            _call.msg.data,
            "ExecWithSigsFacet.execWithSigs:"
        );

        estimatedGasUsed = startGas - gasleft();

        emit LogExecWithSigs(
            _call.correlationId,
            _call.msg,
            executorSigner,
            checkerSigner,
            estimatedGasUsed,
            msg.sender
        );
    }

    // solhint-disable function-max-lines
    /// @param _call Execution payload packed into ExecWithSigsFeeCollector struct
    /// @return estimatedGasUsed Estimated gas used using gas metering
    /// @return observedFee The fee transferred to the fee collector
    function execWithSigsFeeCollector(
        ExecWithSigsFeeCollector calldata _call
    ) external returns (uint256 estimatedGasUsed, uint256 observedFee) {
        uint256 startGas = gasleft();

        require(
            msg.sender == tx.origin,
            "ExecWithSigsFacet.execWithSigsFeeCollector: only EOAs"
        );

        _requireSignerDeadline(
            _call.msg.deadline,
            "ExecWithSigsFacet.execWithSigsFeeCollector._requireSignerDeadline:"
        );

        bytes32 digest = _getDigestFeeCollector(
            _getDomainSeparator(),
            _call.msg
        );

        address executorSigner = _requireExecutorSignerSignature(
            digest,
            _call.executorSignerSig,
            "ExecWithSigsFacet.execWithSigsFeeCollector._requireExecutorSignerSignature:"
        );

        address checkerSigner = _requireCheckerSignerSignature(
            digest,
            _call.checkerSignerSig,
            "ExecWithSigsFacet.execWithSigsFeeCollector._requireCheckerSignerSignature:"
        );

        {
            uint256 preFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeCollector
            );

            // call forward + append fee collector
            _call.msg.service.revertingContractCall(
                _encodeFeeCollector(_call.msg.data, feeCollector),
                "ExecWithSigsFacet.execWithSigsFeeCollector:"
            );

            uint256 postFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeCollector
            );

            observedFee = postFeeTokenBalance - preFeeTokenBalance;
        }

        estimatedGasUsed = startGas - gasleft();

        emit LogExecWithSigsFeeCollector(
            _call.correlationId,
            _call.msg,
            executorSigner,
            checkerSigner,
            observedFee,
            estimatedGasUsed,
            msg.sender
        );
    }

    // solhint-disable function-max-lines
    /// @param _call Execution payload packed into ExecWithSigsRelayContext struct
    /// @return estimatedGasUsed Estimated gas used using gas metering
    /// @return observedFee The fee transferred to the fee collector
    function execWithSigsRelayContext(
        ExecWithSigsRelayContext calldata _call
    ) external returns (uint256 estimatedGasUsed, uint256 observedFee) {
        uint256 startGas = gasleft();

        require(
            msg.sender == tx.origin,
            "ExecWithSigsFacet.execWithSigsRelayContext: only EOAs"
        );

        _requireSignerDeadline(
            _call.msg.deadline,
            "ExecWithSigsFacet.execWithSigsRelayContext._requireSignerDeadline:"
        );

        bytes32 digest = _getDigestRelayContext(
            _getDomainSeparator(),
            _call.msg
        );

        address executorSigner = _requireExecutorSignerSignature(
            digest,
            _call.executorSignerSig,
            "ExecWithSigsFacet.execWithSigsRelayContext._requireExecutorSignerSignature:"
        );

        address checkerSigner = _requireCheckerSignerSignature(
            digest,
            _call.checkerSignerSig,
            "ExecWithSigsFacet.execWithSigsRelayContext._requireCheckerSignerSignature:"
        );

        {
            uint256 preFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeCollector
            );

            // call forward + append fee collector, feeToken, fee
            _call.msg.service.revertingContractCall(
                _encodeRelayContext(
                    _call.msg.data,
                    feeCollector,
                    _call.msg.feeToken,
                    _call.msg.fee
                ),
                "ExecWithSigsFacet.execWithSigsRelayContext:"
            );

            uint256 postFeeTokenBalance = _getBalance(
                _call.msg.feeToken,
                feeCollector
            );

            observedFee = postFeeTokenBalance - preFeeTokenBalance;
        }

        estimatedGasUsed = startGas - gasleft();

        emit LogExecWithSigsRelayContext(
            _call.correlationId,
            _call.msg,
            executorSigner,
            checkerSigner,
            observedFee,
            estimatedGasUsed,
            msg.sender
        );
    }

    /// @dev Used for off-chain simulation only!
    function simulateExecWithSigsTrackFee(
        address _service,
        bytes calldata _data,
        address _feeToken
    )
        external
        returns (
            uint256 estimatedGasUsed,
            uint256 observedFee,
            bool isFeeCollector
        )
    {
        uint256 startGas = gasleft();

        uint256 preFeeCollectorBalance = _getBalance(_feeToken, feeCollector);
        uint256 preDiamondBalance = _getBalance(_feeToken, address(this));

        (bool success, bytes memory returndata) = _service.call(_data);

        uint256 observedFeeCollectorFee = _getBalance(_feeToken, feeCollector) -
            preFeeCollectorBalance;
        uint256 observedDiamondFee = _getBalance(_feeToken, address(this)) -
            preDiamondBalance;

        if (observedDiamondFee > observedFeeCollectorFee) {
            observedFee = observedDiamondFee;
        } else {
            observedFee = observedFeeCollectorFee;
            isFeeCollector = true;
        }

        estimatedGasUsed = startGas - gasleft();

        if (tx.origin != address(0) || !success) {
            _revertWithFeeAndIsFeeCollector(
                success,
                isFeeCollector,
                returndata,
                estimatedGasUsed,
                observedFee
            );
        }
    }

    /// @dev Used for off-chain simulation only!
    function simulateExecWithSigs(
        address _service,
        bytes memory _data
    ) external returns (uint256 estimatedGasUsed) {
        uint256 startGas = gasleft();

        (bool success, bytes memory returndata) = _service.call(_data);

        estimatedGasUsed = startGas - gasleft();

        if (tx.origin != address(0) || !success) {
            _revert(success, returndata, estimatedGasUsed);
        }
    }

    /// @dev Used for off-chain simulation only!
    function simulateExecWithSigsFeeCollector(
        address _service,
        bytes calldata _data,
        address _feeToken
    ) external returns (uint256 estimatedGasUsed, uint256 observedFee) {
        uint256 startGas = gasleft();

        uint256 preFeeTokenBalance = _getBalance(_feeToken, feeCollector);

        (bool success, bytes memory returndata) = _service.call(
            _encodeFeeCollector(_data, feeCollector)
        );

        uint256 postFeeTokenBalance = _getBalance(_feeToken, feeCollector);
        observedFee = postFeeTokenBalance - preFeeTokenBalance;
        estimatedGasUsed = startGas - gasleft();

        if (tx.origin != address(0) || !success) {
            _revertWithFee(success, returndata, estimatedGasUsed, observedFee);
        }
    }

    /// @dev Used for off-chain simulation only!
    function simulateExecWithSigsRelayContext(
        address _service,
        bytes calldata _data,
        address _feeToken,
        uint256 _fee
    ) external returns (uint256 estimatedGasUsed, uint256 observedFee) {
        uint256 startGas = gasleft();

        uint256 preFeeTokenBalance = _getBalance(_feeToken, feeCollector);

        (bool success, bytes memory returndata) = _service.call(
            _encodeRelayContext(_data, feeCollector, _feeToken, _fee)
        );

        uint256 postFeeTokenBalance = _getBalance(_feeToken, feeCollector);
        observedFee = postFeeTokenBalance - preFeeTokenBalance;
        estimatedGasUsed = startGas - gasleft();

        if (tx.origin != address(0) || !success) {
            _revertWithFee(success, returndata, estimatedGasUsed, observedFee);
        }
    }

    //solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32) {
        return _getDomainSeparator();
    }

    function _getDomainSeparator() internal view returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256(
                        bytes(
                            //solhint-disable-next-line max-line-length
                            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
                        )
                    ),
                    keccak256(bytes(name)),
                    keccak256(bytes(version)),
                    block.chainid,
                    address(this)
                )
            );
    }
}

File 2 of 19 : GelatoRelayUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;

// Four different types of calldata packing
// 1. encodeFeeCollector: append 20 byte feeCollector address
// 2. encodeRelayContext: append 20 byte feeCollector address, 20 byte feeToken address, 32 byte uint256 fee
// 3. encodeFeeCollectorERC2771: append 20 byte feeCollector address, 20 byte _msgSender address
// 4. encodeRelayContextERC2771: append 20 byte feeCollector address, 20 byte feeToken address, 32 byte uint256 fee, 20 byte _msgSender address

function _encodeFeeCollector(bytes calldata _data, address _feeCollector)
    pure
    returns (bytes memory)
{
    return abi.encodePacked(_data, _feeCollector);
}

function _encodeRelayContext(
    bytes calldata _data,
    address _feeCollector,
    address _feeToken,
    uint256 _fee
) pure returns (bytes memory) {
    return abi.encodePacked(_data, _feeCollector, _feeToken, _fee);
}

// ERC2771 Encodings

// vanilla ERC2771 context encoding
// solhint-disable-next-line private-vars-leading-underscore, func-visibility
function _encodeERC2771Context(bytes calldata _data, address _msgSender)
    pure
    returns (bytes memory)
{
    return abi.encodePacked(_data, _msgSender);
}

function _encodeFeeCollectorERC2771(
    bytes calldata _data,
    address _feeCollector,
    address _msgSender
) pure returns (bytes memory) {
    return abi.encodePacked(_data, _feeCollector, _msgSender);
}

function _encodeRelayContextERC2771(
    bytes calldata _data,
    address _feeCollector,
    address _feeToken,
    uint256 _fee,
    address _msgSender
) pure returns (bytes memory) {
    return abi.encodePacked(_data, _feeCollector, _feeToken, _fee, _msgSender);
}

File 3 of 19 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 4 of 19 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 5 of 19 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 6 of 19 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 7 of 19 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 8 of 19 : Tokens.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

address constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

File 9 of 19 : BFacetOwner.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {LibDiamond} from "../../libraries/diamond/standard/LibDiamond.sol";

abstract contract BFacetOwner {
    modifier onlyOwner() {
        LibDiamond.enforceIsContractOwner();
        _;
    }
}

File 10 of 19 : ExecWithSigsBase.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {GelatoString} from "../../libraries/GelatoString.sol";
import {
    _wasSignatureUsedAlready,
    _setWasSignatureUsedAlready
} from "../storage/ExecWithSigsStorage.sol";
import {
    _isExecutorSigner,
    _isCheckerSigner
} from "../storage/SignerStorage.sol";
import {
    ExecWithSigs,
    Message,
    ExecWithSigsFeeCollector,
    MessageFeeCollector,
    MessageTrackFee,
    ExecWithSigsRelayContext,
    MessageRelayContext
} from "../../types/CallTypes.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

abstract contract ExecWithSigsBase {
    using GelatoString for string;

    bytes32 public constant MESSAGE_TYPEHASH =
        keccak256(
            bytes(
                // solhint-disable-next-line max-line-length
                "Message(address service,bytes data,uint256 salt,uint256 deadline)"
            )
        );

    bytes32 public constant MESSAGE_FEE_COLLECTOR_TYPEHASH =
        keccak256(
            bytes(
                // solhint-disable-next-line max-line-length
                "MessageFeeCollector(address service,bytes data,uint256 salt,uint256 deadline,address feeToken)"
            )
        );

    bytes32 public constant MESSAGE_TRACK_FEE =
        keccak256(
            bytes(
                // solhint-disable-next-line max-line-length
                "MessageTrackFee(address service,bytes data,uint256 salt,uint256 deadline,address feeToken,bool isFeeCollector)"
            )
        );

    bytes32 public constant MESSAGE_RELAY_CONTEXT_TYPEHASH =
        keccak256(
            bytes(
                // solhint-disable-next-line max-line-length
                "MessageRelayContext(address service,bytes data,uint256 salt,uint256 deadline,address feeToken,uint256 fee)"
            )
        );

    function _requireSignerDeadline(
        uint256 _signerDeadline,
        string memory _errorTrace
    ) internal view {
        require(
            // solhint-disable-next-line not-rely-on-time
            _signerDeadline == 0 || _signerDeadline >= block.timestamp,
            _errorTrace.suffix("deadline")
        );
    }

    function _requireExecutorSignerSignature(
        bytes32 _digest,
        bytes calldata _executorSignerSig,
        string memory _errorTrace
    ) internal returns (address executorSigner) {
        require(
            !_wasSignatureUsedAlready(_executorSignerSig),
            _errorTrace.suffix("replay")
        );

        ECDSA.RecoverError error;
        (executorSigner, error) = ECDSA.tryRecover(_digest, _executorSignerSig);

        require(
            error == ECDSA.RecoverError.NoError &&
                _isExecutorSigner(executorSigner),
            _errorTrace.suffix("ECDSA.RecoverError.NoError && isExecutorSigner")
        );

        _setWasSignatureUsedAlready(_executorSignerSig);
    }

    function _requireCheckerSignerSignature(
        bytes32 _digest,
        bytes calldata _checkerSignerSig,
        string memory _errorTrace
    ) internal returns (address checkerSigner) {
        require(
            !_wasSignatureUsedAlready(_checkerSignerSig),
            _errorTrace.suffix("replay")
        );

        ECDSA.RecoverError error;
        (checkerSigner, error) = ECDSA.tryRecover(_digest, _checkerSignerSig);

        require(
            error == ECDSA.RecoverError.NoError &&
                _isCheckerSigner(checkerSigner),
            _errorTrace.suffix("ECDSA.RecoverError.NoError && isCheckerSigner")
        );

        _setWasSignatureUsedAlready(_checkerSignerSig);
    }

    function _getDigest(
        bytes32 _domainSeparator,
        Message calldata _msg
    ) internal pure returns (bytes32 digest) {
        digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                _domainSeparator,
                keccak256(_abiEncodeExecWithSigs(_msg))
            )
        );
    }

    function _getDigestFeeCollector(
        bytes32 _domainSeparator,
        MessageFeeCollector calldata _msg
    ) internal pure returns (bytes32 digest) {
        digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                _domainSeparator,
                keccak256(_abiEncodeExecWithSigsFeeCollector(_msg))
            )
        );
    }

    function _getDigestTrackFee(
        bytes32 _domainSeparator,
        MessageTrackFee calldata _msg
    ) internal pure returns (bytes32 digest) {
        digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                _domainSeparator,
                keccak256(_abiEncodeExecWithSigsTrackFee(_msg))
            )
        );
    }

    function _getDigestRelayContext(
        bytes32 _domainSeparator,
        MessageRelayContext calldata _msg
    ) internal pure returns (bytes32 digest) {
        digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                _domainSeparator,
                keccak256(_abiEncodeExecWithSigsRelayContext(_msg))
            )
        );
    }

    function _abiEncodeExecWithSigs(
        Message calldata _msg
    ) internal pure returns (bytes memory) {
        return
            abi.encode(
                MESSAGE_TYPEHASH,
                _msg.service,
                keccak256(_msg.data),
                _msg.salt,
                _msg.deadline
            );
    }

    function _abiEncodeExecWithSigsFeeCollector(
        MessageFeeCollector calldata _msg
    ) internal pure returns (bytes memory) {
        return
            abi.encode(
                MESSAGE_FEE_COLLECTOR_TYPEHASH,
                _msg.service,
                keccak256(_msg.data),
                _msg.salt,
                _msg.deadline,
                _msg.feeToken
            );
    }

    function _abiEncodeExecWithSigsTrackFee(
        MessageTrackFee calldata _msg
    ) internal pure returns (bytes memory) {
        return
            abi.encode(
                MESSAGE_TRACK_FEE,
                _msg.service,
                keccak256(_msg.data),
                _msg.salt,
                _msg.deadline,
                _msg.feeToken,
                _msg.isFeeCollector
            );
    }

    function _abiEncodeExecWithSigsRelayContext(
        MessageRelayContext calldata _msg
    ) internal pure returns (bytes memory) {
        return
            abi.encode(
                MESSAGE_RELAY_CONTEXT_TYPEHASH,
                _msg.service,
                keccak256(_msg.data),
                _msg.salt,
                _msg.deadline,
                _msg.feeToken,
                _msg.fee
            );
    }
}

File 11 of 19 : ExecWithSigsStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

struct ExecWithSigsStorage {
    mapping(bytes32 => bool) wasSignatureUsedAlready;
}

bytes32 constant _EXEC_WITH_SIGS_STORAGE = keccak256(
    "gelato.diamond.execWithSigs.storage"
);

function _wasSignatureUsedAlready(bytes calldata _signature)
    view
    returns (bool)
{
    return
        _execWithSigsStorage().wasSignatureUsedAlready[keccak256(_signature)];
}

function _setWasSignatureUsedAlready(bytes calldata _signature) {
    _execWithSigsStorage().wasSignatureUsedAlready[
        keccak256(_signature)
    ] = true;
}

//solhint-disable-next-line private-vars-leading-underscore
function _execWithSigsStorage()
    pure
    returns (ExecWithSigsStorage storage ewss)
{
    bytes32 position = _EXEC_WITH_SIGS_STORAGE;
    assembly {
        ewss.slot := position
    }
}

File 12 of 19 : SignerStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {
    EnumerableSet
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

using EnumerableSet for EnumerableSet.AddressSet;

struct SignerStorage {
    EnumerableSet.AddressSet executorSigners;
    EnumerableSet.AddressSet checkerSigners;
}

bytes32 constant _SIGNER_STORAGE_POSITION = keccak256(
    "gelato.diamond.signer.storage"
);

function _addExecutorSigner(address _executor) returns (bool) {
    return _signerStorage().executorSigners.add(_executor);
}

function _removeExecutorSigner(address _executor) returns (bool) {
    return _signerStorage().executorSigners.remove(_executor);
}

function _isExecutorSigner(address _executorSigner) view returns (bool) {
    return _signerStorage().executorSigners.contains(_executorSigner);
}

function _executorSignerAt(uint256 _index) view returns (address) {
    return _signerStorage().executorSigners.at(_index);
}

function _executorSigners() view returns (address[] memory) {
    return _signerStorage().executorSigners.values();
}

function _numberOfExecutorSigners() view returns (uint256) {
    return _signerStorage().executorSigners.length();
}

function _addCheckerSigner(address _checker) returns (bool) {
    return _signerStorage().checkerSigners.add(_checker);
}

function _removeCheckerSigner(address _checker) returns (bool) {
    return _signerStorage().checkerSigners.remove(_checker);
}

function _isCheckerSigner(address _checker) view returns (bool) {
    return _signerStorage().checkerSigners.contains(_checker);
}

function _checkerSignerAt(uint256 _index) view returns (address) {
    return _signerStorage().checkerSigners.at(_index);
}

function _checkerSigners() view returns (address[] memory checkers) {
    return _signerStorage().checkerSigners.values();
}

function _numberOfCheckerSigners() view returns (uint256) {
    return _signerStorage().checkerSigners.length();
}

function _signerStorage() pure returns (SignerStorage storage ess) {
    bytes32 position = _SIGNER_STORAGE_POSITION;
    assembly {
        ess.slot := position
    }
}

File 13 of 19 : Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {NATIVE_TOKEN} from "../constants/Tokens.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

function _getBalance(address token, address user) view returns (uint256) {
    if (token == address(0)) return 0;
    return token == NATIVE_TOKEN ? user.balance : IERC20(token).balanceOf(user);
}

function _simulateAndRevert(
    address _service,
    uint256 _gasleft,
    bytes memory _data
) {
    assembly {
        let success := call(
            gas(),
            _service,
            0,
            add(_data, 0x20),
            mload(_data),
            0,
            0
        )

        mstore(0x00, success) // store success bool in first word
        mstore(0x20, sub(_gasleft, gas())) // store gas after success
        mstore(0x40, returndatasize()) // store length of return data size in third word
        returndatacopy(0x60, 0, returndatasize()) // store actual return data in fourth word and onwards
        revert(0, add(returndatasize(), 0x60))
    }
}

function _revert(
    bool _success,
    bytes memory _returndata,
    uint256 _estimatedGasUsed
) pure {
    bytes memory revertData = bytes.concat(
        abi.encode(_success, _estimatedGasUsed, _returndata.length),
        _returndata
    );
    assembly {
        revert(add(32, revertData), mload(revertData))
    }
}

function _revertWithFee(
    bool _success,
    bytes memory _returndata,
    uint256 _estimatedGasUsed,
    uint256 _observedFee
) pure {
    bytes memory revertData = bytes.concat(
        abi.encode(
            _success,
            _estimatedGasUsed,
            _observedFee,
            _returndata.length
        ),
        _returndata
    );
    assembly {
        revert(add(32, revertData), mload(revertData))
    }
}

function _revertWithFeeAndIsFeeCollector(
    bool _success,
    bool _isFeeCollector,
    bytes memory _returndata,
    uint256 _estimatedGasUsed,
    uint256 _observedFee
) pure {
    bytes memory revertData = bytes.concat(
        abi.encode(
            _success,
            _estimatedGasUsed,
            _observedFee,
            _isFeeCollector,
            _returndata.length
        ),
        _returndata
    );
    assembly {
        revert(add(32, revertData), mload(revertData))
    }
}

File 14 of 19 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamond Standard: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamondCut {
    enum FacetCutAction {
        Add,
        Replace,
        Remove
    }
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;
}

File 15 of 19 : GelatoBytes.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

library GelatoBytes {
    function calldataSliceSelector(
        bytes calldata _bytes
    ) internal pure returns (bytes4 selector) {
        selector =
            _bytes[0] |
            (bytes4(_bytes[1]) >> 8) |
            (bytes4(_bytes[2]) >> 16) |
            (bytes4(_bytes[3]) >> 24);
    }

    function memorySliceSelector(
        bytes memory _bytes
    ) internal pure returns (bytes4 selector) {
        selector =
            _bytes[0] |
            (bytes4(_bytes[1]) >> 8) |
            (bytes4(_bytes[2]) >> 16) |
            (bytes4(_bytes[3]) >> 24);
    }

    function revertWithError(
        bytes memory _bytes,
        string memory _tracingInfo
    ) internal pure {
        // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err
        if (_bytes.length % 32 == 4) {
            bytes4 selector;
            assembly {
                selector := mload(add(0x20, _bytes))
            }
            if (selector == 0x08c379a0) {
                // Function selector for Error(string)
                assembly {
                    _bytes := add(_bytes, 68)
                }
                revert(string(abi.encodePacked(_tracingInfo, string(_bytes))));
            } else {
                revert(
                    string(abi.encodePacked(_tracingInfo, "NoErrorSelector"))
                );
            }
        } else {
            revert(
                string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata"))
            );
        }
    }

    function returnError(
        bytes memory _bytes,
        string memory _tracingInfo
    ) internal pure returns (string memory) {
        // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err
        if (_bytes.length % 32 == 4) {
            bytes4 selector;
            assembly {
                selector := mload(add(0x20, _bytes))
            }
            if (selector == 0x08c379a0) {
                // Function selector for Error(string)
                assembly {
                    _bytes := add(_bytes, 68)
                }
                return string(abi.encodePacked(_tracingInfo, string(_bytes)));
            } else {
                return
                    string(abi.encodePacked(_tracingInfo, "NoErrorSelector"));
            }
        } else {
            return
                string(abi.encodePacked(_tracingInfo, "UnexpectedReturndata"));
        }
    }
}

File 16 of 19 : GelatoCallUtils.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {GelatoBytes} from "./GelatoBytes.sol";

library GelatoCallUtils {
    using GelatoBytes for bytes;

    function revertingContractCall(
        address _contract,
        bytes memory _data,
        string memory _errorMsg
    ) internal returns (bytes memory returndata) {
        bool success;
        (success, returndata) = _contract.call(_data);

        // solhint-disable-next-line max-line-length
        // https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L177
        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(_contract),
                    string(abi.encodePacked(_errorMsg, "Call to non contract"))
                );
            }
        } else {
            returndata.revertWithError(_errorMsg);
        }
    }

    // solhint-disable-next-line max-line-length
    // https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f9b6fc3fdab7aca33a9cfa8837c5cd7f67e176be/contracts/utils/AddressUpgradeable.sol#L36
    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;
    }
}

File 17 of 19 : GelatoString.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

library GelatoString {
    function startsWithOK(string memory _str) internal pure returns (bool) {
        if (
            bytes(_str).length >= 2 &&
            bytes(_str)[0] == "O" &&
            bytes(_str)[1] == "K"
        ) return true;
        return false;
    }

    function revertWithInfo(
        string memory _error,
        string memory _tracingInfo
    ) internal pure {
        revert(string(abi.encodePacked(_tracingInfo, _error)));
    }

    function prefix(
        string memory _second,
        string memory _first
    ) internal pure returns (string memory) {
        return string(abi.encodePacked(_first, _second));
    }

    function suffix(
        string memory _first,
        string memory _second
    ) internal pure returns (string memory) {
        return string(abi.encodePacked(_first, _second));
    }
}

File 18 of 19 : LibDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
// solhint-disable max-line-length
// https://github.com/mudgen/diamond-3/blob/b009cd08b7822bad727bbcc47aa1b50d8b50f7f0/contracts/libraries/LibDiamond.sol#L1

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamond Standard: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

import "../../../interfaces/diamond/standard/IDiamondCut.sol";

// Custom due to incorrect string casting (non UTF-8 formatted)
import {GelatoBytes} from "../../../libraries/GelatoBytes.sol";

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION =
        keccak256("diamond.standard.diamond.storage");

    struct FacetAddressAndPosition {
        address facetAddress;
        uint16 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array
    }

    struct FacetFunctionSelectors {
        bytes4[] functionSelectors;
        uint16 facetAddressPosition; // position of facetAddress in facetAddresses array
    }

    struct DiamondStorage {
        // maps function selector to the facet address and
        // the position of the selector in the facetFunctionSelectors.selectors array
        mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition;
        // maps facet addresses to function selectors
        mapping(address => FacetFunctionSelectors) facetFunctionSelectors;
        // facet addresses
        address[] facetAddresses;
        // Used to query if a contract implements an interface.
        // Used to implement ERC-165.
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage()
        internal
        pure
        returns (DiamondStorage storage ds)
    {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

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

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function isContractOwner(address _guy) internal view returns (bool) {
        return _guy == contractOwner();
    }

    function enforceIsContractOwner() internal view {
        require(
            msg.sender == diamondStorage().contractOwner,
            "LibDiamond: Must be contract owner"
        );
    }

    event DiamondCut(
        IDiamondCut.FacetCut[] _diamondCut,
        address _init,
        bytes _calldata
    );

    // Internal function version of diamondCut
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        for (
            uint256 facetIndex;
            facetIndex < _diamondCut.length;
            facetIndex++
        ) {
            IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action;
            if (action == IDiamondCut.FacetCutAction.Add) {
                addFunctions(
                    _diamondCut[facetIndex].facetAddress,
                    _diamondCut[facetIndex].functionSelectors
                );
            } else if (action == IDiamondCut.FacetCutAction.Replace) {
                replaceFunctions(
                    _diamondCut[facetIndex].facetAddress,
                    _diamondCut[facetIndex].functionSelectors
                );
            } else if (action == IDiamondCut.FacetCutAction.Remove) {
                removeFunctions(
                    _diamondCut[facetIndex].facetAddress,
                    _diamondCut[facetIndex].functionSelectors
                );
            } else {
                revert("LibDiamondCut: Incorrect FacetCutAction");
            }
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        require(
            _functionSelectors.length > 0,
            "LibDiamondCut: No selectors in facet to cut"
        );
        DiamondStorage storage ds = diamondStorage();
        // uint16 selectorCount = uint16(diamondStorage().selectors.length);
        require(
            _facetAddress != address(0),
            "LibDiamondCut: Add facet can't be address(0)"
        );
        uint16 selectorPosition = uint16(
            ds.facetFunctionSelectors[_facetAddress].functionSelectors.length
        );
        // add new facet address if it does not exist
        if (selectorPosition == 0) {
            enforceHasContractCode(
                _facetAddress,
                "LibDiamondCut: New facet has no code"
            );
            ds
                .facetFunctionSelectors[_facetAddress]
                .facetAddressPosition = uint16(ds.facetAddresses.length);
            ds.facetAddresses.push(_facetAddress);
        }
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldFacetAddress = ds
                .selectorToFacetAndPosition[selector]
                .facetAddress;
            require(
                oldFacetAddress == address(0),
                "LibDiamondCut: Can't add function that already exists"
            );
            ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(
                selector
            );
            ds
                .selectorToFacetAndPosition[selector]
                .facetAddress = _facetAddress;
            ds
                .selectorToFacetAndPosition[selector]
                .functionSelectorPosition = selectorPosition;
            selectorPosition++;
        }
    }

    function replaceFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        require(
            _functionSelectors.length > 0,
            "LibDiamondCut: No selectors in facet to cut"
        );
        DiamondStorage storage ds = diamondStorage();
        require(
            _facetAddress != address(0),
            "LibDiamondCut: Add facet can't be address(0)"
        );
        uint16 selectorPosition = uint16(
            ds.facetFunctionSelectors[_facetAddress].functionSelectors.length
        );
        // add new facet address if it does not exist
        if (selectorPosition == 0) {
            enforceHasContractCode(
                _facetAddress,
                "LibDiamondCut: New facet has no code"
            );
            ds
                .facetFunctionSelectors[_facetAddress]
                .facetAddressPosition = uint16(ds.facetAddresses.length);
            ds.facetAddresses.push(_facetAddress);
        }
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldFacetAddress = ds
                .selectorToFacetAndPosition[selector]
                .facetAddress;
            require(
                oldFacetAddress != _facetAddress,
                "LibDiamondCut: Can't replace function with same function"
            );
            removeFunction(oldFacetAddress, selector);
            // add function
            ds
                .selectorToFacetAndPosition[selector]
                .functionSelectorPosition = selectorPosition;
            ds.facetFunctionSelectors[_facetAddress].functionSelectors.push(
                selector
            );
            ds
                .selectorToFacetAndPosition[selector]
                .facetAddress = _facetAddress;
            selectorPosition++;
        }
    }

    function removeFunctions(
        address _facetAddress,
        bytes4[] memory _functionSelectors
    ) internal {
        require(
            _functionSelectors.length > 0,
            "LibDiamondCut: No selectors in facet to cut"
        );
        DiamondStorage storage ds = diamondStorage();
        // if function does not exist then do nothing and return
        require(
            _facetAddress == address(0),
            "LibDiamondCut: Remove facet address must be address(0)"
        );
        for (
            uint256 selectorIndex;
            selectorIndex < _functionSelectors.length;
            selectorIndex++
        ) {
            bytes4 selector = _functionSelectors[selectorIndex];
            address oldFacetAddress = ds
                .selectorToFacetAndPosition[selector]
                .facetAddress;
            removeFunction(oldFacetAddress, selector);
        }
    }

    function removeFunction(address _facetAddress, bytes4 _selector) internal {
        DiamondStorage storage ds = diamondStorage();
        require(
            _facetAddress != address(0),
            "LibDiamondCut: Can't remove function that doesn't exist"
        );
        // an immutable function is a function defined directly in a diamond
        require(
            _facetAddress != address(this),
            "LibDiamondCut: Can't remove immutable function"
        );
        // replace selector with last selector, then delete last selector
        uint256 selectorPosition = ds
            .selectorToFacetAndPosition[_selector]
            .functionSelectorPosition;
        uint256 lastSelectorPosition = ds
            .facetFunctionSelectors[_facetAddress]
            .functionSelectors
            .length - 1;
        // if not the same then replace _selector with lastSelector
        if (selectorPosition != lastSelectorPosition) {
            bytes4 lastSelector = ds
                .facetFunctionSelectors[_facetAddress]
                .functionSelectors[lastSelectorPosition];
            ds.facetFunctionSelectors[_facetAddress].functionSelectors[
                    selectorPosition
                ] = lastSelector;
            ds
                .selectorToFacetAndPosition[lastSelector]
                .functionSelectorPosition = uint16(selectorPosition);
        }
        // delete the last selector
        ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop();
        delete ds.selectorToFacetAndPosition[_selector];

        // if no more selectors for facet address then delete the facet address
        if (lastSelectorPosition == 0) {
            // replace facet address with last facet address and delete last facet address
            uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1;
            uint256 facetAddressPosition = ds
                .facetFunctionSelectors[_facetAddress]
                .facetAddressPosition;
            if (facetAddressPosition != lastFacetAddressPosition) {
                address lastFacetAddress = ds.facetAddresses[
                    lastFacetAddressPosition
                ];
                ds.facetAddresses[facetAddressPosition] = lastFacetAddress;
                ds
                    .facetFunctionSelectors[lastFacetAddress]
                    .facetAddressPosition = uint16(facetAddressPosition);
            }
            ds.facetAddresses.pop();
            delete ds
                .facetFunctionSelectors[_facetAddress]
                .facetAddressPosition;
        }
    }

    function initializeDiamondCut(address _init, bytes memory _calldata)
        internal
    {
        if (_init == address(0)) {
            require(
                _calldata.length == 0,
                "LibDiamondCut: _init is address(0) but_calldata is not empty"
            );
        } else {
            require(
                _calldata.length > 0,
                "LibDiamondCut: _calldata is empty but _init is not address(0)"
            );
            if (_init != address(this)) {
                enforceHasContractCode(
                    _init,
                    "LibDiamondCut: _init address has no code"
                );
            }
            (bool success, bytes memory error) = _init.delegatecall(_calldata);
            if (!success) {
                if (error.length > 0) {
                    // bubble up the error
                    GelatoBytes.revertWithError(error, "LibDiamondCut:_init:");
                } else {
                    revert("LibDiamondCut: _init function reverted");
                }
            }
        }
    }

    function enforceHasContractCode(
        address _contract,
        string memory _errorMessage
    ) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        require(contractSize > 0, _errorMessage);
    }
}

File 19 of 19 : CallTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

struct Message {
    address service;
    bytes data;
    uint256 salt;
    uint256 deadline;
}

struct MessageFeeCollector {
    address service;
    bytes data;
    uint256 salt;
    uint256 deadline;
    address feeToken;
}

struct MessageTrackFee {
    address service;
    bytes data;
    uint256 salt;
    uint256 deadline;
    address feeToken;
    bool isFeeCollector;
}

struct MessageRelayContext {
    address service;
    bytes data;
    uint256 salt;
    uint256 deadline;
    address feeToken;
    uint256 fee;
}

struct ExecWithSigs {
    bytes32 correlationId;
    Message msg;
    bytes executorSignerSig;
    bytes checkerSignerSig;
}

struct ExecWithSigsFeeCollector {
    bytes32 correlationId;
    MessageFeeCollector msg;
    bytes executorSignerSig;
    bytes checkerSignerSig;
}

struct ExecWithSigsTrackFee {
    bytes32 correlationId;
    MessageTrackFee msg;
    bytes executorSignerSig;
    bytes checkerSignerSig;
}

struct ExecWithSigsRelayContext {
    bytes32 correlationId;
    MessageRelayContext msg;
    bytes executorSignerSig;
    bytes checkerSignerSig;
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"indexed":false,"internalType":"struct Message","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigs","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"indexed":false,"internalType":"struct MessageFeeCollector","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"observedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigsFeeCollector","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"indexed":false,"internalType":"struct MessageRelayContext","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"observedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigsRelayContext","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"bool","name":"isFeeCollector","type":"bool"}],"indexed":false,"internalType":"struct MessageTrackFee","name":"msg","type":"tuple"},{"indexed":true,"internalType":"address","name":"executorSigner","type":"address"},{"indexed":true,"internalType":"address","name":"checkerSigner","type":"address"},{"indexed":false,"internalType":"uint256","name":"observedFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"LogExecWithSigsTrackFee","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_FEE_COLLECTOR_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_RELAY_CONTEXT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_TRACK_FEE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MESSAGE_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct Message","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigs","name":"_call","type":"tuple"}],"name":"execWithSigs","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"}],"internalType":"struct MessageFeeCollector","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigsFeeCollector","name":"_call","type":"tuple"}],"name":"execWithSigsFeeCollector","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"fee","type":"uint256"}],"internalType":"struct MessageRelayContext","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigsRelayContext","name":"_call","type":"tuple"}],"name":"execWithSigsRelayContext","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"bytes32","name":"correlationId","type":"bytes32"},{"components":[{"internalType":"address","name":"service","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"bool","name":"isFeeCollector","type":"bool"}],"internalType":"struct MessageTrackFee","name":"msg","type":"tuple"},{"internalType":"bytes","name":"executorSignerSig","type":"bytes"},{"internalType":"bytes","name":"checkerSignerSig","type":"bytes"}],"internalType":"struct ExecWithSigsTrackFee","name":"_call","type":"tuple"}],"name":"execWithSigsTrackFee","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"simulateExecWithSigs","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_feeToken","type":"address"}],"name":"simulateExecWithSigsFeeCollector","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_feeToken","type":"address"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"simulateExecWithSigsRelayContext","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_service","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"address","name":"_feeToken","type":"address"}],"name":"simulateExecWithSigsTrackFee","outputs":[{"internalType":"uint256","name":"estimatedGasUsed","type":"uint256"},{"internalType":"uint256","name":"observedFee","type":"uint256"},{"internalType":"bool","name":"isFeeCollector","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]

60a06040523480156200001157600080fd5b5060405162002d2838038062002d28833981016040819052620000349162000046565b6001600160a01b031660805262000078565b6000602082840312156200005957600080fd5b81516001600160a01b03811681146200007157600080fd5b9392505050565b608051612c40620000e86000396000818161024a015281816104020152818161044b01528181610579015281816105b301528181610635015281816109c701528181610a6801528181610c5b01528181610f55015281816110600152818161109a015261111a0152612c406000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806354fd4d501161009757806383ec30771161006657806383ec30771461023d578063c415b95c14610245578063cd2cf36614610284578063f111786a1461029757600080fd5b806354fd4d50146101c757806367c62fe0146101e7578063684a4b2b146101fa578063697649c91461022a57600080fd5b80633644e515116100d35780633644e5151461019c5780634522589f146101a457806346e356b1146101b7578063544dd395146101bf57600080fd5b806306fdde03146101055780630a4806ce1461014b57806314036783146101735780631c367bc314610189575b600080fd5b61013560405180604001604052806011815260200170115e1958d5da5d1a14da59dcd19858d95d607a1b81525081565b6040516101429190611e42565b60405180910390f35b61015e610159366004611e8d565b6102aa565b60408051928352602083019190915201610142565b61017b610546565b604051908152602001610142565b61015e610197366004611f28565b610569565b61017b6106a0565b61017b6101b2366004611e8d565b6106af565b61017b6108d6565b61017b6108f9565b610135604051806040016040528060018152602001603160f81b81525081565b61017b6101f5366004611fab565b61091c565b61020d61020836600461206d565b6109b6565b604080519384526020840192909252151590820152606001610142565b61015e610238366004611e8d565b610b05565b61017b610dcd565b61026c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610142565b61015e610292366004611e8d565b610df0565b61015e6102a536600461206d565b611050565b60008060005a90503332146103245760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e657865635769746853696773466560448201527465436f6c6c6563746f723a206f6e6c7920454f417360581b60648201526084015b60405180910390fd5b61035661033460208601866120d2565b60600135604051806080016040528060428152602001612af560429139611184565b60006103756103636111de565b61037060208801886120d2565b6112b9565b905060006103a88261038a60408901896120f2565b6040518060800160405280604b81526020016128c3604b913961130f565b905060006103db836103bd60608a018a6120f2565b6040518060800160405280604a81526020016129c3604a913961142d565b905060006104266103ef60208a018a6120d2565b6104009060a0810190608001612139565b7f0000000000000000000000000000000000000000000000000000000000000000611519565b90506104b361046f61043b60208b018b6120d2565b6104499060208101906120f2565b7f00000000000000000000000000000000000000000000000000000000000000006115d9565b6040518060600160405280602b8152602001612ba1602b913961049560208c018c6120d2565b6104a3906020810190612139565b6001600160a01b03169190611608565b5060006104c66103ef60208b018b6120d2565b90506104d28282612154565b965050505a6104e19085612154565b95506001600160a01b038082169083167febee01ccf79a62d5083b2b10c32a7991d2c2acfc80c6d73c0380901c888ccbc1893561052160208c018c6120d2565b898b336040516105359594939291906121e4565b60405180910390a350505050915091565b6040518060a00160405280606e8152602001612782606e91398051906020012081565b60008060005a9050600061059d867f0000000000000000000000000000000000000000000000000000000000000000611519565b90506000808a6001600160a01b03166105d98b8b7f00000000000000000000000000000000000000000000000000000000000000008c8c6116de565b6040516105e69190612276565b6000604051808303816000865af19150503d8060008114610623576040519150601f19603f3d011682016040523d82523d6000602084013e610628565b606091505b50915091506000610659897f0000000000000000000000000000000000000000000000000000000000000000611519565b90506106658482612154565b95505a6106729086612154565b965032151580610680575082155b156106915761069183838989611713565b50505050509550959350505050565b60006106aa6111de565b905090565b6000805a90503332146107165760405162461bcd60e51b815260206004820152602960248201527f45786563576974685369677346616365742e6578656357697468536967733a206044820152686f6e6c7920454f417360b81b606482015260840161031b565b6107486107266020850185612288565b6060013560405180606001604052806036815260200161294c60369139611184565b60006107676107556111de565b6107626020870187612288565b611775565b9050600061079a8261077c60408801886120f2565b6040518060600160405280603f8152602001612bcc603f913961130f565b905060006107cd836107af60608901896120f2565b6040518060600160405280603e8152602001612a8a603e913961142d565b90506108676107df6020880188612288565b6107ed9060208101906120f2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051808201909152601f81527f45786563576974685369677346616365742e6578656357697468536967733a0060208083019190915290925061049591508a018a612288565b505a6108739085612154565b94506001600160a01b038082169083167f7bfffe4b1a7ee0d5ebb45f7d8b0eea0a4ddfa94221b2325b850e5a5925e5e97088356108b360208b018b612288565b89336040516108c5949392919061229e565b60405180910390a350505050919050565b604051806080016040528060418152602001612982604191398051906020012081565b6040518060a00160405280606a8152602001612b37606a91398051906020012081565b6000805a9050600080856001600160a01b03168560405161093d9190612276565b6000604051808303816000865af19150503d806000811461097a576040519150601f19603f3d011682016040523d82523d6000602084013e61097f565b606091505b50915091505a61098f9084612154565b93503215158061099d575081155b156109ad576109ad828286611781565b50505092915050565b6000806000805a905060006109eb867f0000000000000000000000000000000000000000000000000000000000000000611519565b905060006109f98730611519565b90506000808b6001600160a01b03168b8b604051610a18929190612313565b6000604051808303816000865af19150503d8060008114610a55576040519150601f19603f3d011682016040523d82523d6000602084013e610a5a565b606091505b5091509150600084610a8c8b7f0000000000000000000000000000000000000000000000000000000000000000611519565b610a969190612154565b9050600084610aa58c30611519565b610aaf9190612154565b905081811115610ac157809850610ac9565b819850600197505b5a610ad49088612154565b995032151580610ae2575083155b15610af457610af48489858d8d6117c2565b505050505050509450945094915050565b60008060005a9050333214610b765760405162461bcd60e51b815260206004820152603160248201527f45786563576974685369677346616365742e657865635769746853696773547260448201527061636b4665653a206f6e6c7920454f417360781b606482015260840161031b565b610ba8610b866020860186612323565b606001356040518060600160405280603e815260200161290e603e9139611184565b6000610bc7610bb56111de565b610bc26020880188612323565b6117f8565b90506000610bfa82610bdc60408901896120f2565b60405180608001604052806047815260200161263e6047913961130f565b90506000610c2d83610c0f60608a018a6120f2565b60405180608001604052806046815260200161283b6046913961142d565b90506000610c3e6020890189612323565b610c4f9060c081019060a001612349565b610c595730610c7b565b7f00000000000000000000000000000000000000000000000000000000000000005b90506000610ca6610c8f60208b018b612323565b610ca09060a0810190608001612139565b83611519565b9050610d22610cb860208b018b612323565b610cc69060208101906120f2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051606081019091526027808252909250905061275b602083013961049560208d018d612323565b506000610d4c610d3560208c018c612323565b610d469060a0810190608001612139565b84611519565b9050610d588282612154565b975050505a610d679086612154565b96506001600160a01b038083169084167f01de45c8dc2b958d357d4feda6c44ab6865ab3ab7b4f2a1f338a75116a0c36378a35610da760208d018d612323565b8a8c33604051610dbb959493929190612364565b60405180910390a35050505050915091565b6040518060800160405280605e81526020016126cf605e91398051906020012081565b60008060005a9050333214610e655760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e65786563576974685369677352656044820152746c6179436f6e746578743a206f6e6c7920454f417360581b606482015260840161031b565b610e97610e756020860186612323565b6060013560405180608001604052806042815260200161288160429139611184565b6000610eb6610ea46111de565b610eb16020880188612323565b611804565b90506000610ee982610ecb60408901896120f2565b6040518060800160405280604b81526020016127f0604b913961130f565b90506000610f1c83610efe60608a018a6120f2565b6040518060800160405280604a8152602001612685604a913961142d565b90506000610f306103ef60208a018a612323565b9050610fce610fa8610f4560208b018b612323565b610f539060208101906120f2565b7f0000000000000000000000000000000000000000000000000000000000000000610f8160208e018e612323565b610f929060a0810190608001612139565b610f9f60208f018f612323565b60a001356116de565b6040518060600160405280602b8152602001612a5f602b913961049560208c018c612323565b506000610fe16103ef60208b018b612323565b9050610fed8282612154565b965050505a610ffc9085612154565b95506001600160a01b038082169083167fa5c57cb93d2124da6530c224fa6138483ff7ecd2959d2dad024a9d050076cc1a893561103c60208c018c612323565b898b3360405161053595949392919061241a565b60008060005a90506000611084857f0000000000000000000000000000000000000000000000000000000000000000611519565b9050600080896001600160a01b03166110be8a8a7f00000000000000000000000000000000000000000000000000000000000000006115d9565b6040516110cb9190612276565b6000604051808303816000865af19150503d8060008114611108576040519150601f19603f3d011682016040523d82523d6000602084013e61110d565b606091505b5091509150600061113e887f0000000000000000000000000000000000000000000000000000000000000000611519565b905061114a8482612154565b95505a6111579086612154565b965032151580611165575082155b156111765761117683838989611713565b505050505094509492505050565b8115806111915750428210155b604080518082019091526008815267646561646c696e6560c01b60208201526111bb908390611810565b906111d95760405162461bcd60e51b815260040161031b9190611e42565b505050565b6000604051806080016040528060528152602001612a0d6052913980516020918201206040805180820182526011815270115e1958d5da5d1a14da59dcd19858d95d607a1b908401528051808201825260018152603160f81b908401528051928301919091527f176566dd3634ff88354f49a20832f5507a82745dc224d42b5843c5e757ade4b5908201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6000826112c58361183c565b80516020918201206040516112f193920161190160f01b81526002810192909252602282015260420190565b60405160208183030381529060405280519060200120905092915050565b600061131b84846118fc565b1561134d604051806040016040528060068152602001657265706c617960d01b8152508461181090919063ffffffff16565b9061136b5760405162461bcd60e51b815260040161031b9190611e42565b5060006113ae8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061195692505050565b909250905060008160048111156113c7576113c76124bd565b1480156113d857506113d88261199b565b6113fb6040518060600160405280602e815260200161272d602e91398590611810565b906114195760405162461bcd60e51b815260040161031b9190611e42565b5061142485856119e5565b50949350505050565b600061143984846118fc565b1561146b604051806040016040528060068152602001657265706c617960d01b8152508461181090919063ffffffff16565b906114895760405162461bcd60e51b815260040161031b9190611e42565b5060006114cc8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061195692505050565b909250905060008160048111156114e5576114e56124bd565b1480156114f657506114f682611a4c565b6113fb6040518060600160405280602d8152602001612ac8602d91398590611810565b60006001600160a01b038316611531575060006115d3565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146115c4576040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561159b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115bf91906124d3565b6115d0565b816001600160a01b0316315b90505b92915050565b60608383836040516020016115f0939291906124ec565b60405160208183030381529060405290509392505050565b60606000846001600160a01b0316846040516116249190612276565b6000604051808303816000865af19150503d8060008114611661576040519150601f19603f3d011682016040523d82523d6000602084013e611666565b606091505b509250905080156116cc5781516000036116c7576001600160a01b0385163b1515836040516020016116989190612512565b604051602081830303815290604052906116c55760405162461bcd60e51b815260040161031b9190611e42565b505b6116d6565b6116d68284611ab5565b509392505050565b606085858585856040516020016116f995949392919061254a565b604051602081830303815290604052905095945050505050565b825160408051861515602082015290810184905260608101839052608081019190915260009060a0015b60408051601f198184030181529082905261175c918690602001612581565b6040516020818303038152906040529050805181602001fd5b6000826112c583611b47565b8151604080518515156020820152908101839052606081019190915260009060800160408051601f198184030181529082905261175c918590602001612581565b825160408051871515602082015290810184905260608101839052851515608082015260a081019190915260009060c00161173d565b6000826112c583611bd6565b6000826112c583611c9e565b60608282604051602001611825929190612581565b604051602081830303815290604052905092915050565b60606040518060800160405280605e81526020016126cf605e913980516020918201209061186c90840184612139565b61187960208501856120f2565b604051611887929190612313565b6040518091039020846040013585606001358660800160208101906118ac9190612139565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a08401521660c082015260e0015b6040516020818303038152906040529050919050565b60007f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d61164446040516000906119329086908690612313565b604080519182900390912082526020820192909252016000205460ff169392505050565b600080825160410361198c5760208301516040840151606085015160001a61198087828585611d5a565b94509450505050611994565b506000905060025b9250929050565b60006115d3827fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d0906001600160a01b038116600090815260018301602052604081205415156115d0565b60017f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d6116444604051600090611a1b9086908690612313565b6040518091039020815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6001600160a01b03811660009081527fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d360205260408120546115d3907fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d2908490849015156115d0565b60208251611ac391906125b0565b600403611b365760208201516001600160e01b0319811662461bcd60e51b03611b25576044830192508183604051602001611aff929190612581565b60408051601f198184030181529082905262461bcd60e51b825261031b91600401611e42565b81604051602001611aff91906125d2565b80604051602001611aff9190612605565b606060405180608001604052806041815260200161298260419139805160209182012090611b7790840184612139565b611b8460208501856120f2565b604051611b92929190612313565b6040805191829003822060208301949094526001600160a01b03909216818301526060808201939093529084013560808201529083013560a082015260c0016118e6565b60606040518060a00160405280606e8152602001612782606e9139805160209182012090611c0690840184612139565b611c1360208501856120f2565b604051611c21929190612313565b604051809103902084604001358560600135866080016020810190611c469190612139565b611c5660c0890160a08a01612349565b6040805160208101989098526001600160a01b03968716908801526060870194909452608086019290925260a085015290911660c0830152151560e0820152610100016118e6565b60606040518060a00160405280606a8152602001612b37606a9139805160209182012090611cce90840184612139565b611cdb60208501856120f2565b604051611ce9929190612313565b604051809103902084604001358560600135866080016020810190611d0e9190612139565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a084810191909152911660c083015283013560e0820152610100016118e6565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611d915750600090506003611e15565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611de5573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611e0e57600060019250925050611e15565b9150600090505b94509492505050565b60005b83811015611e39578181015183820152602001611e21565b50506000910152565b6020815260008251806020840152611e61816040850160208701611e1e565b601f01601f19169190910160400192915050565b600060808284031215611e8757600080fd5b50919050565b600060208284031215611e9f57600080fd5b813567ffffffffffffffff811115611eb657600080fd5b611ec284828501611e75565b949350505050565b80356001600160a01b0381168114611ee157600080fd5b919050565b60008083601f840112611ef857600080fd5b50813567ffffffffffffffff811115611f1057600080fd5b60208301915083602082850101111561199457600080fd5b600080600080600060808688031215611f4057600080fd5b611f4986611eca565b9450602086013567ffffffffffffffff811115611f6557600080fd5b611f7188828901611ee6565b9095509350611f84905060408701611eca565b949793965091946060013592915050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215611fbe57600080fd5b611fc783611eca565b9150602083013567ffffffffffffffff80821115611fe457600080fd5b818501915085601f830112611ff857600080fd5b81358181111561200a5761200a611f95565b604051601f8201601f19908116603f0116810190838211818310171561203257612032611f95565b8160405282815288602084870101111561204b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000806000806060858703121561208357600080fd5b61208c85611eca565b9350602085013567ffffffffffffffff8111156120a857600080fd5b6120b487828801611ee6565b90945092506120c7905060408601611eca565b905092959194509250565b60008235609e198336030181126120e857600080fd5b9190910192915050565b6000808335601e1984360301811261210957600080fd5b83018035915067ffffffffffffffff82111561212457600080fd5b60200191503681900382131561199457600080fd5b60006020828403121561214b57600080fd5b6115d082611eca565b818103818111156115d357634e487b7160e01b600052601160045260246000fd5b6000808335601e1984360301811261218c57600080fd5b830160208101925035905067ffffffffffffffff8111156121ac57600080fd5b80360382131561199457600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815260a0602082015260006001600160a01b038061220288611eca565b1660a08401526122156020880188612175565b60a060c086015261222b610140860182846121bb565b915050604088013560e085015260608801356101008501528161225060808a01611eca565b166101208501526040840196909652606083019490945250911660809091015292915050565b600082516120e8818460208701611e1e565b60008235607e198336030181126120e857600080fd5b8481526080602082015260006001600160a01b03806122bc87611eca565b1660808401526122cf6020870187612175565b608060a08601526122e5610100860182846121bb565b60408981013560c08801526060998a013560e088015286019790975250509290921693019290925292915050565b8183823760009101908152919050565b6000823560be198336030181126120e857600080fd5b80358015158114611ee157600080fd5b60006020828403121561235b57600080fd5b6115d082612339565b85815260a0602082015260006001600160a01b038061238288611eca565b1660a08401526123956020880188612175565b60c0808601526123aa610160860182846121bb565b915050604088013560e08501526060880135610100850152816123cf60808a01611eca565b166101208501526123e260a08901612339565b1515610140850152809250505084604083015283606083015261241060808301846001600160a01b03169052565b9695505050505050565b85815260a0602082015260006001600160a01b038061243888611eca565b1660a084015261244b6020880188612175565b60c080860152612460610160860182846121bb565b915050604088013560e085015260608801356101008501528161248560808a01611eca565b1661012085015260a0880135610140850152809250505084604083015283606083015261241060808301846001600160a01b03169052565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156124e557600080fd5b5051919050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b60008251612524818460208701611e1e565b7310d85b1b081d1bc81b9bdb8818dbdb9d1c9858dd60621b920191825250601401919050565b848682376bffffffffffffffffffffffff19606094851b8116959091019485529190921b1660148301526028820152604801919050565b60008351612593818460208801611e1e565b8351908301906125a7818360208801611e1e565b01949350505050565b6000826125cd57634e487b7160e01b600052601260045260246000fd5b500690565b600082516125e4818460208701611e1e565b6e2737a2b93937b929b2b632b1ba37b960891b920191825250600f01919050565b60008251612617818460208701611e1e565b73556e657870656374656452657475726e6461746160601b92019182525060140191905056fe45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f72657175697265436865636b65725369676e65725369676e61747572653a4d657373616765466565436f6c6c6563746f72286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2945434453412e5265636f7665724572726f722e4e6f4572726f722026262069734578656375746f725369676e657245786563576974685369677346616365742e657865635769746853696773547261636b4665653a4d657373616765547261636b466565286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2c626f6f6c206973466565436f6c6c6563746f722945786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f72657175697265436865636b65725369676e65725369676e61747572653a45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972655369676e6572446561646c696e653a45786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f726571756972655369676e6572446561646c696e653a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972655369676e6572446561646c696e653a4d657373616765286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f72657175697265436865636b65725369676e65725369676e61747572653a454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742945786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578743a45786563576974685369677346616365742e6578656357697468536967732e5f72657175697265436865636b65725369676e65725369676e61747572653a45434453412e5265636f7665724572726f722e4e6f4572726f72202626206973436865636b65725369676e657245786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972655369676e6572446561646c696e653a4d65737361676552656c6179436f6e74657874286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2c75696e74323536206665652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f723a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972654578656375746f725369676e65725369676e61747572653aa26469706673582212209f43d990f4b5bf67ae2128b7474601636243340fbc45aba8f0dac93bbe10721064736f6c634300081100330000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101005760003560e01c806354fd4d501161009757806383ec30771161006657806383ec30771461023d578063c415b95c14610245578063cd2cf36614610284578063f111786a1461029757600080fd5b806354fd4d50146101c757806367c62fe0146101e7578063684a4b2b146101fa578063697649c91461022a57600080fd5b80633644e515116100d35780633644e5151461019c5780634522589f146101a457806346e356b1146101b7578063544dd395146101bf57600080fd5b806306fdde03146101055780630a4806ce1461014b57806314036783146101735780631c367bc314610189575b600080fd5b61013560405180604001604052806011815260200170115e1958d5da5d1a14da59dcd19858d95d607a1b81525081565b6040516101429190611e42565b60405180910390f35b61015e610159366004611e8d565b6102aa565b60408051928352602083019190915201610142565b61017b610546565b604051908152602001610142565b61015e610197366004611f28565b610569565b61017b6106a0565b61017b6101b2366004611e8d565b6106af565b61017b6108d6565b61017b6108f9565b610135604051806040016040528060018152602001603160f81b81525081565b61017b6101f5366004611fab565b61091c565b61020d61020836600461206d565b6109b6565b604080519384526020840192909252151590820152606001610142565b61015e610238366004611e8d565b610b05565b61017b610dcd565b61026c7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf81565b6040516001600160a01b039091168152602001610142565b61015e610292366004611e8d565b610df0565b61015e6102a536600461206d565b611050565b60008060005a90503332146103245760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e657865635769746853696773466560448201527465436f6c6c6563746f723a206f6e6c7920454f417360581b60648201526084015b60405180910390fd5b61035661033460208601866120d2565b60600135604051806080016040528060428152602001612af560429139611184565b60006103756103636111de565b61037060208801886120d2565b6112b9565b905060006103a88261038a60408901896120f2565b6040518060800160405280604b81526020016128c3604b913961130f565b905060006103db836103bd60608a018a6120f2565b6040518060800160405280604a81526020016129c3604a913961142d565b905060006104266103ef60208a018a6120d2565b6104009060a0810190608001612139565b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b90506104b361046f61043b60208b018b6120d2565b6104499060208101906120f2565b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf6115d9565b6040518060600160405280602b8152602001612ba1602b913961049560208c018c6120d2565b6104a3906020810190612139565b6001600160a01b03169190611608565b5060006104c66103ef60208b018b6120d2565b90506104d28282612154565b965050505a6104e19085612154565b95506001600160a01b038082169083167febee01ccf79a62d5083b2b10c32a7991d2c2acfc80c6d73c0380901c888ccbc1893561052160208c018c6120d2565b898b336040516105359594939291906121e4565b60405180910390a350505050915091565b6040518060a00160405280606e8152602001612782606e91398051906020012081565b60008060005a9050600061059d867f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b90506000808a6001600160a01b03166105d98b8b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf8c8c6116de565b6040516105e69190612276565b6000604051808303816000865af19150503d8060008114610623576040519150601f19603f3d011682016040523d82523d6000602084013e610628565b606091505b50915091506000610659897f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b90506106658482612154565b95505a6106729086612154565b965032151580610680575082155b156106915761069183838989611713565b50505050509550959350505050565b60006106aa6111de565b905090565b6000805a90503332146107165760405162461bcd60e51b815260206004820152602960248201527f45786563576974685369677346616365742e6578656357697468536967733a206044820152686f6e6c7920454f417360b81b606482015260840161031b565b6107486107266020850185612288565b6060013560405180606001604052806036815260200161294c60369139611184565b60006107676107556111de565b6107626020870187612288565b611775565b9050600061079a8261077c60408801886120f2565b6040518060600160405280603f8152602001612bcc603f913961130f565b905060006107cd836107af60608901896120f2565b6040518060600160405280603e8152602001612a8a603e913961142d565b90506108676107df6020880188612288565b6107ed9060208101906120f2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051808201909152601f81527f45786563576974685369677346616365742e6578656357697468536967733a0060208083019190915290925061049591508a018a612288565b505a6108739085612154565b94506001600160a01b038082169083167f7bfffe4b1a7ee0d5ebb45f7d8b0eea0a4ddfa94221b2325b850e5a5925e5e97088356108b360208b018b612288565b89336040516108c5949392919061229e565b60405180910390a350505050919050565b604051806080016040528060418152602001612982604191398051906020012081565b6040518060a00160405280606a8152602001612b37606a91398051906020012081565b6000805a9050600080856001600160a01b03168560405161093d9190612276565b6000604051808303816000865af19150503d806000811461097a576040519150601f19603f3d011682016040523d82523d6000602084013e61097f565b606091505b50915091505a61098f9084612154565b93503215158061099d575081155b156109ad576109ad828286611781565b50505092915050565b6000806000805a905060006109eb867f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b905060006109f98730611519565b90506000808b6001600160a01b03168b8b604051610a18929190612313565b6000604051808303816000865af19150503d8060008114610a55576040519150601f19603f3d011682016040523d82523d6000602084013e610a5a565b606091505b5091509150600084610a8c8b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b610a969190612154565b9050600084610aa58c30611519565b610aaf9190612154565b905081811115610ac157809850610ac9565b819850600197505b5a610ad49088612154565b995032151580610ae2575083155b15610af457610af48489858d8d6117c2565b505050505050509450945094915050565b60008060005a9050333214610b765760405162461bcd60e51b815260206004820152603160248201527f45786563576974685369677346616365742e657865635769746853696773547260448201527061636b4665653a206f6e6c7920454f417360781b606482015260840161031b565b610ba8610b866020860186612323565b606001356040518060600160405280603e815260200161290e603e9139611184565b6000610bc7610bb56111de565b610bc26020880188612323565b6117f8565b90506000610bfa82610bdc60408901896120f2565b60405180608001604052806047815260200161263e6047913961130f565b90506000610c2d83610c0f60608a018a6120f2565b60405180608001604052806046815260200161283b6046913961142d565b90506000610c3e6020890189612323565b610c4f9060c081019060a001612349565b610c595730610c7b565b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf5b90506000610ca6610c8f60208b018b612323565b610ca09060a0810190608001612139565b83611519565b9050610d22610cb860208b018b612323565b610cc69060208101906120f2565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505060408051606081019091526027808252909250905061275b602083013961049560208d018d612323565b506000610d4c610d3560208c018c612323565b610d469060a0810190608001612139565b84611519565b9050610d588282612154565b975050505a610d679086612154565b96506001600160a01b038083169084167f01de45c8dc2b958d357d4feda6c44ab6865ab3ab7b4f2a1f338a75116a0c36378a35610da760208d018d612323565b8a8c33604051610dbb959493929190612364565b60405180910390a35050505050915091565b6040518060800160405280605e81526020016126cf605e91398051906020012081565b60008060005a9050333214610e655760405162461bcd60e51b815260206004820152603560248201527f45786563576974685369677346616365742e65786563576974685369677352656044820152746c6179436f6e746578743a206f6e6c7920454f417360581b606482015260840161031b565b610e97610e756020860186612323565b6060013560405180608001604052806042815260200161288160429139611184565b6000610eb6610ea46111de565b610eb16020880188612323565b611804565b90506000610ee982610ecb60408901896120f2565b6040518060800160405280604b81526020016127f0604b913961130f565b90506000610f1c83610efe60608a018a6120f2565b6040518060800160405280604a8152602001612685604a913961142d565b90506000610f306103ef60208a018a612323565b9050610fce610fa8610f4560208b018b612323565b610f539060208101906120f2565b7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf610f8160208e018e612323565b610f929060a0810190608001612139565b610f9f60208f018f612323565b60a001356116de565b6040518060600160405280602b8152602001612a5f602b913961049560208c018c612323565b506000610fe16103ef60208b018b612323565b9050610fed8282612154565b965050505a610ffc9085612154565b95506001600160a01b038082169083167fa5c57cb93d2124da6530c224fa6138483ff7ecd2959d2dad024a9d050076cc1a893561103c60208c018c612323565b898b3360405161053595949392919061241a565b60008060005a90506000611084857f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b9050600080896001600160a01b03166110be8a8a7f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf6115d9565b6040516110cb9190612276565b6000604051808303816000865af19150503d8060008114611108576040519150601f19603f3d011682016040523d82523d6000602084013e61110d565b606091505b5091509150600061113e887f0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf611519565b905061114a8482612154565b95505a6111579086612154565b965032151580611165575082155b156111765761117683838989611713565b505050505094509492505050565b8115806111915750428210155b604080518082019091526008815267646561646c696e6560c01b60208201526111bb908390611810565b906111d95760405162461bcd60e51b815260040161031b9190611e42565b505050565b6000604051806080016040528060528152602001612a0d6052913980516020918201206040805180820182526011815270115e1958d5da5d1a14da59dcd19858d95d607a1b908401528051808201825260018152603160f81b908401528051928301919091527f176566dd3634ff88354f49a20832f5507a82745dc224d42b5843c5e757ade4b5908201527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160405160208183030381529060405280519060200120905090565b6000826112c58361183c565b80516020918201206040516112f193920161190160f01b81526002810192909252602282015260420190565b60405160208183030381529060405280519060200120905092915050565b600061131b84846118fc565b1561134d604051806040016040528060068152602001657265706c617960d01b8152508461181090919063ffffffff16565b9061136b5760405162461bcd60e51b815260040161031b9190611e42565b5060006113ae8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061195692505050565b909250905060008160048111156113c7576113c76124bd565b1480156113d857506113d88261199b565b6113fb6040518060600160405280602e815260200161272d602e91398590611810565b906114195760405162461bcd60e51b815260040161031b9190611e42565b5061142485856119e5565b50949350505050565b600061143984846118fc565b1561146b604051806040016040528060068152602001657265706c617960d01b8152508461181090919063ffffffff16565b906114895760405162461bcd60e51b815260040161031b9190611e42565b5060006114cc8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061195692505050565b909250905060008160048111156114e5576114e56124bd565b1480156114f657506114f682611a4c565b6113fb6040518060600160405280602d8152602001612ac8602d91398590611810565b60006001600160a01b038316611531575060006115d3565b6001600160a01b03831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146115c4576040516370a0823160e01b81526001600160a01b0383811660048301528416906370a0823190602401602060405180830381865afa15801561159b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115bf91906124d3565b6115d0565b816001600160a01b0316315b90505b92915050565b60608383836040516020016115f0939291906124ec565b60405160208183030381529060405290509392505050565b60606000846001600160a01b0316846040516116249190612276565b6000604051808303816000865af19150503d8060008114611661576040519150601f19603f3d011682016040523d82523d6000602084013e611666565b606091505b509250905080156116cc5781516000036116c7576001600160a01b0385163b1515836040516020016116989190612512565b604051602081830303815290604052906116c55760405162461bcd60e51b815260040161031b9190611e42565b505b6116d6565b6116d68284611ab5565b509392505050565b606085858585856040516020016116f995949392919061254a565b604051602081830303815290604052905095945050505050565b825160408051861515602082015290810184905260608101839052608081019190915260009060a0015b60408051601f198184030181529082905261175c918690602001612581565b6040516020818303038152906040529050805181602001fd5b6000826112c583611b47565b8151604080518515156020820152908101839052606081019190915260009060800160408051601f198184030181529082905261175c918590602001612581565b825160408051871515602082015290810184905260608101839052851515608082015260a081019190915260009060c00161173d565b6000826112c583611bd6565b6000826112c583611c9e565b60608282604051602001611825929190612581565b604051602081830303815290604052905092915050565b60606040518060800160405280605e81526020016126cf605e913980516020918201209061186c90840184612139565b61187960208501856120f2565b604051611887929190612313565b6040518091039020846040013585606001358660800160208101906118ac9190612139565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a08401521660c082015260e0015b6040516020818303038152906040529050919050565b60007f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d61164446040516000906119329086908690612313565b604080519182900390912082526020820192909252016000205460ff169392505050565b600080825160410361198c5760208301516040840151606085015160001a61198087828585611d5a565b94509450505050611994565b506000905060025b9250929050565b60006115d3827fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d0906001600160a01b038116600090815260018301602052604081205415156115d0565b60017f90f0bdc952e556bcffe177d42d0a1e2c48fc4212efc230d6acee71a6d6116444604051600090611a1b9086908690612313565b6040518091039020815260200190815260200160002060006101000a81548160ff0219169083151502179055505050565b6001600160a01b03811660009081527fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d360205260408120546115d3907fdee078fadc21593590e9046d81e4518a7b3feb16bdee74b2d2488cd4455264d2908490849015156115d0565b60208251611ac391906125b0565b600403611b365760208201516001600160e01b0319811662461bcd60e51b03611b25576044830192508183604051602001611aff929190612581565b60408051601f198184030181529082905262461bcd60e51b825261031b91600401611e42565b81604051602001611aff91906125d2565b80604051602001611aff9190612605565b606060405180608001604052806041815260200161298260419139805160209182012090611b7790840184612139565b611b8460208501856120f2565b604051611b92929190612313565b6040805191829003822060208301949094526001600160a01b03909216818301526060808201939093529084013560808201529083013560a082015260c0016118e6565b60606040518060a00160405280606e8152602001612782606e9139805160209182012090611c0690840184612139565b611c1360208501856120f2565b604051611c21929190612313565b604051809103902084604001358560600135866080016020810190611c469190612139565b611c5660c0890160a08a01612349565b6040805160208101989098526001600160a01b03968716908801526060870194909452608086019290925260a085015290911660c0830152151560e0820152610100016118e6565b60606040518060a00160405280606a8152602001612b37606a9139805160209182012090611cce90840184612139565b611cdb60208501856120f2565b604051611ce9929190612313565b604051809103902084604001358560600135866080016020810190611d0e9190612139565b6040805160208101979097526001600160a01b03958616908701526060860193909352608085019190915260a084810191909152911660c083015283013560e0820152610100016118e6565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611d915750600090506003611e15565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611de5573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611e0e57600060019250925050611e15565b9150600090505b94509492505050565b60005b83811015611e39578181015183820152602001611e21565b50506000910152565b6020815260008251806020840152611e61816040850160208701611e1e565b601f01601f19169190910160400192915050565b600060808284031215611e8757600080fd5b50919050565b600060208284031215611e9f57600080fd5b813567ffffffffffffffff811115611eb657600080fd5b611ec284828501611e75565b949350505050565b80356001600160a01b0381168114611ee157600080fd5b919050565b60008083601f840112611ef857600080fd5b50813567ffffffffffffffff811115611f1057600080fd5b60208301915083602082850101111561199457600080fd5b600080600080600060808688031215611f4057600080fd5b611f4986611eca565b9450602086013567ffffffffffffffff811115611f6557600080fd5b611f7188828901611ee6565b9095509350611f84905060408701611eca565b949793965091946060013592915050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215611fbe57600080fd5b611fc783611eca565b9150602083013567ffffffffffffffff80821115611fe457600080fd5b818501915085601f830112611ff857600080fd5b81358181111561200a5761200a611f95565b604051601f8201601f19908116603f0116810190838211818310171561203257612032611f95565b8160405282815288602084870101111561204b57600080fd5b8260208601602083013760006020848301015280955050505050509250929050565b6000806000806060858703121561208357600080fd5b61208c85611eca565b9350602085013567ffffffffffffffff8111156120a857600080fd5b6120b487828801611ee6565b90945092506120c7905060408601611eca565b905092959194509250565b60008235609e198336030181126120e857600080fd5b9190910192915050565b6000808335601e1984360301811261210957600080fd5b83018035915067ffffffffffffffff82111561212457600080fd5b60200191503681900382131561199457600080fd5b60006020828403121561214b57600080fd5b6115d082611eca565b818103818111156115d357634e487b7160e01b600052601160045260246000fd5b6000808335601e1984360301811261218c57600080fd5b830160208101925035905067ffffffffffffffff8111156121ac57600080fd5b80360382131561199457600080fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b85815260a0602082015260006001600160a01b038061220288611eca565b1660a08401526122156020880188612175565b60a060c086015261222b610140860182846121bb565b915050604088013560e085015260608801356101008501528161225060808a01611eca565b166101208501526040840196909652606083019490945250911660809091015292915050565b600082516120e8818460208701611e1e565b60008235607e198336030181126120e857600080fd5b8481526080602082015260006001600160a01b03806122bc87611eca565b1660808401526122cf6020870187612175565b608060a08601526122e5610100860182846121bb565b60408981013560c08801526060998a013560e088015286019790975250509290921693019290925292915050565b8183823760009101908152919050565b6000823560be198336030181126120e857600080fd5b80358015158114611ee157600080fd5b60006020828403121561235b57600080fd5b6115d082612339565b85815260a0602082015260006001600160a01b038061238288611eca565b1660a08401526123956020880188612175565b60c0808601526123aa610160860182846121bb565b915050604088013560e08501526060880135610100850152816123cf60808a01611eca565b166101208501526123e260a08901612339565b1515610140850152809250505084604083015283606083015261241060808301846001600160a01b03169052565b9695505050505050565b85815260a0602082015260006001600160a01b038061243888611eca565b1660a084015261244b6020880188612175565b60c080860152612460610160860182846121bb565b915050604088013560e085015260608801356101008501528161248560808a01611eca565b1661012085015260a0880135610140850152809250505084604083015283606083015261241060808301846001600160a01b03169052565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156124e557600080fd5b5051919050565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b60008251612524818460208701611e1e565b7310d85b1b081d1bc81b9bdb8818dbdb9d1c9858dd60621b920191825250601401919050565b848682376bffffffffffffffffffffffff19606094851b8116959091019485529190921b1660148301526028820152604801919050565b60008351612593818460208801611e1e565b8351908301906125a7818360208801611e1e565b01949350505050565b6000826125cd57634e487b7160e01b600052601260045260246000fd5b500690565b600082516125e4818460208701611e1e565b6e2737a2b93937b929b2b632b1ba37b960891b920191825250600f01919050565b60008251612617818460208701611e1e565b73556e657870656374656452657475726e6461746160601b92019182525060140191905056fe45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f72657175697265436865636b65725369676e65725369676e61747572653a4d657373616765466565436f6c6c6563746f72286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2945434453412e5265636f7665724572726f722e4e6f4572726f722026262069734578656375746f725369676e657245786563576974685369677346616365742e657865635769746853696773547261636b4665653a4d657373616765547261636b466565286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2c626f6f6c206973466565436f6c6c6563746f722945786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f72657175697265436865636b65725369676e65725369676e61747572653a45786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578742e5f726571756972655369676e6572446561646c696e653a45786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972654578656375746f725369676e65725369676e61747572653a45786563576974685369677346616365742e657865635769746853696773547261636b4665652e5f726571756972655369676e6572446561646c696e653a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972655369676e6572446561646c696e653a4d657373616765286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f72657175697265436865636b65725369676e65725369676e61747572653a454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e74726163742945786563576974685369677346616365742e65786563576974685369677352656c6179436f6e746578743a45786563576974685369677346616365742e6578656357697468536967732e5f72657175697265436865636b65725369676e65725369676e61747572653a45434453412e5265636f7665724572726f722e4e6f4572726f72202626206973436865636b65725369676e657245786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f722e5f726571756972655369676e6572446561646c696e653a4d65737361676552656c6179436f6e74657874286164647265737320736572766963652c627974657320646174612c75696e743235362073616c742c75696e7432353620646561646c696e652c6164647265737320666565546f6b656e2c75696e74323536206665652945786563576974685369677346616365742e657865635769746853696773466565436f6c6c6563746f723a45786563576974685369677346616365742e6578656357697468536967732e5f726571756972654578656375746f725369676e65725369676e61747572653aa26469706673582212209f43d990f4b5bf67ae2128b7474601636243340fbc45aba8f0dac93bbe10721064736f6c63430008110033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf

-----Decoded View---------------
Arg [0] : _feeCollector (address): 0x3AC05161b76a35c1c28dC99Aa01BEd7B24cEA3bf

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000003ac05161b76a35c1c28dc99aa01bed7b24cea3bf


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.