ETH Price: $2,526.98 (+3.14%)

Contract

0x588e3A2b9a94d45a1a132ac948f2377FE48f2625
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x60c06040169665932023-04-03 6:00:11518 days ago1680501611IN
 Create: ParcelPayroll
0 ETH0.064925418.53709267

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ParcelPayroll

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion
File 1 of 21 : ParcelPayroll.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/MerkleProofUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";

import "./payroll/ApproverManager.sol";
import "./interfaces/IAllowanceModule.sol";

// Errors
error CannotRenounceOwnership();
error SweepFailed(address tokenAddress, uint256 amount);
error InvalidPayoutSignature(bytes signature);
error PayrollDataLengthMismatch();
error RootSignatureLengthMismatch();
error PaymentTokenLengthMismatch();
error TokensLeftInContract(address tokenAddress);
error PayoutNonceAlreadyExecuted(uint64 nonce);
error TokensNotSorted(address tokenAddress1, address tokenAddress2);
error UnauthorizedTransfer();
error InvalidSignatureLength();

/**
 * @title ParcelPayroll
 * @dev ParcelPayroll is a secure and decentralized smart contract designed to help organizations pay their contributors with ease and efficiency. The contract utilizes a dedicated approval team, removing the reliance on the organization's multisig, which helps to streamline the payment process and ensure secure payments.
 *
 * One of the key features of ParcelPayroll is its ability to improve approver coordination. Approvers can approve payouts in non-aligned batches, meaning they don't all need to approve the same payouts at the same time. This feature saves time and resources for the organization, as approvers can approve payouts when they are available, rather than being constrained by a strict schedule.
 *
 * With ParcelPayroll, organizations can automate their payment processes, reducing the risk of errors and increasing efficiency. The contract's decentralized architecture ensures that all transactions are transparent and auditable, adding an extra layer of security to the payment process.
 *
 * @author Sriram Kasyap Meduri - <[email protected]>
 * @author Krishna Kant Sharma - <[email protected]>
 */

contract ParcelPayroll is
    UUPSUpgradeable,
    OwnableUpgradeable,
    ReentrancyGuardUpgradeable,
    PausableUpgradeable,
    ApproverManager
{
    using SafeERC20Upgradeable for IERC20Upgradeable;
    using ECDSAUpgradeable for bytes32;

    /**
     * @dev Emitted when the contract is initialized
     * @param orgAddress - Address of the organization's safe
     * @param approvers - Array of approver addresses
     * @param approvalsRequired - Number of approvals required for a payout to be executed
     */
    event OrgSetup(
        address indexed orgAddress,
        address[] indexed approvers,
        uint128 approvalsRequired
    );

    /**
     * @dev Emitted when a payout is successfully executed
     * @param tokenAddress - Address of the token being paid out
     * @param to - Address of the recipient
     * @param amount - Amount being paid out
     * @param payoutNonce - Nonce of the payout
     */
    event PayoutSuccessful(
        address tokenAddress,
        address to,
        uint256 amount,
        uint256 payoutNonce
    );

    /**
     * @dev Emitted when a payout execution fails
     * @param tokenAddress - Address of the token being paid out
     * @param to - Address of the recipient
     * @param amount - Amount being paid out
     * @param payoutNonce - Nonce of the payout
     */
    event PayoutFailed(
        address tokenAddress,
        address to,
        uint256 amount,
        uint256 payoutNonce
    );

    /**
     * @dev Constructor
     */
    constructor() {
        // So that the contract cannot be initialized again and become singleton
        _disableInitializers();
    }

    /**
     * @dev Receive Native tokens
     */
    receive() external payable {}

    /**
     * @dev Initialize the payroll contract. Called when a new payroll contract is deployed / org is onboarded
     * @param _approvers - Array of approver addresses
     * @param approvalsRequired - Number of approvals required for a payout to be executed
     */
    function initialize(
        address safeAddress,
        address[] calldata _approvers,
        uint128 approvalsRequired
    ) external initializer {
        _transferOwnership(safeAddress);
        __Pausable_init();
        __ReentrancyGuard_init();
        __UUPSUpgradeable_init();

        _cachedDomainSeparator = _buildDomainSeparator(address(this));
        _cachedThis = address(this);

        setupApprovers(_approvers, approvalsRequired);
        emit OrgSetup(safeAddress, _approvers, approvalsRequired);
    }

    /**
     * @dev Helper function to execute an ERC20 transfer safely for the try catch block. This can only be called by the contract itself
     * @param token - Address of the token to transfer
     * @param to - Address of the recipient
     * @param amount - Amount to transfer
     */
    function safeTransferExternal(
        IERC20Upgradeable token,
        address to,
        uint256 amount
    ) external {
        if (msg.sender != address(this)) revert UnauthorizedTransfer();

        token.safeTransfer(to, amount);
    }

    /**
     * @dev Validate the payroll transaction hashes and execute the payroll
     * @param to Addresses to send the funds to
     * @param tokenAddress Addresses of the tokens to send
     * @param amount Amounts of tokens to send
     * @param payoutNonce Payout nonces to use
     * @param proof Merkle proof of the payroll transaction hashes
     * @param roots Merkle roots of the payroll transaction hashes
     * @param signatures Signatures of the payroll transaction hashes
     * @notice In a Batch of payouts, if one payout fails, the rest of the batch is continued after emitting the PayoutFailed event. In this case, the amount of the failed payout is left on the contract. The sweep function can be used to return the failed payout amount to the org safe in a separate transaction.
     */
    function executePayroll(
        address[] memory to,
        address[] memory tokenAddress,
        uint128[] memory amount,
        uint64[] memory payoutNonce,
        bytes32[][][] memory proof,
        bytes32[] memory roots,
        bytes[] memory signatures
    ) external nonReentrant whenNotPaused {
        // Caching array lengths
        uint128 payoutLength = uint128(to.length);
        uint128 rootLength = uint128(roots.length);
        bool[] memory isApproved = new bool[](payoutLength);

        // Validate the Input Data
        if (
            payoutLength == 0 ||
            payoutLength != tokenAddress.length ||
            payoutLength != amount.length ||
            payoutLength != payoutNonce.length
        ) revert PayrollDataLengthMismatch();

        if (rootLength != signatures.length)
            revert RootSignatureLengthMismatch();

        validateSignatures(roots, signatures);

        {
            // Initialize the flag token amount to fetch
            uint256 tokenFlagAmountToFetch = 0;

            // Initialize the flag token address
            address tokenFlag = tokenAddress[0];

            // Initialize the approvals array

            // Loop through the payouts
            for (uint256 i = 0; i < payoutLength; i++) {
                // Revert if the payout nonce has already been executed
                if (getPayoutNonce(payoutNonce[i]))
                    revert PayoutNonceAlreadyExecuted(payoutNonce[i]);

                // Generate the leaf from the payout data
                bytes32 leaf = encodeTransactionData(
                    to[i],
                    tokenAddress[i],
                    amount[i],
                    payoutNonce[i]
                );

                // Initialize the approvals counter
                uint256 approvals;

                // Loop through the roots
                for (
                    uint256 j = 0;
                    j < rootLength && approvals < threshold;
                    j++
                ) {
                    // Verify the root has been validated
                    // Verify the proof against the current root and increment the approvals counter

                    if (
                        MerkleProofUpgradeable.verify(
                            proof[i][j],
                            roots[j],
                            leaf
                        )
                    ) {
                        ++approvals;
                    }
                }

                // Check if the approvals are greater than or equal to the required approvals
                if (approvals >= threshold) {
                    // Set the approval to true
                    isApproved[i] = true;

                    // Check if the token address is the same as the flag token address
                    if (tokenFlag != tokenAddress[i]) {
                        // Enforce ascending order of token addresses
                        if (tokenFlag > tokenAddress[i])
                            revert TokensNotSorted(tokenFlag, tokenAddress[i]);

                        // Fetch the flag token from Gnosis
                        execTransactionFromGnosis(
                            tokenFlag,
                            uint96(tokenFlagAmountToFetch)
                        );
                        // Set the flag token address to the current token address
                        tokenFlag = tokenAddress[i];
                        // Reset the flag token amount to fetch
                        tokenFlagAmountToFetch = 0;
                    }
                    // Add the current payout amount to the flag token amount to fetch
                    tokenFlagAmountToFetch += amount[i];
                }
            }
            if (tokenFlagAmountToFetch > 0) {
                // Fetch the flag token from Gnosis
                execTransactionFromGnosis(
                    tokenFlag,
                    uint96(tokenFlagAmountToFetch)
                );
            }
        }
        // Loop through the approvals
        for (uint256 i = 0; i < payoutLength; i++) {
            // Transfer the funds to the recipient (to) addresses
            if (isApproved[i] && !getPayoutNonce(payoutNonce[i])) {
                if (tokenAddress[i] == address(0)) {
                    // Transfer Native tokens
                    (bool sent, bytes memory data) = to[i].call{
                        value: amount[i]
                    }("");

                    if (!sent) {
                        emit PayoutFailed(
                            address(0),
                            to[i],
                            amount[i],
                            payoutNonce[i]
                        );
                    } else {
                        packPayoutNonce(payoutNonce[i]);
                        emit PayoutSuccessful(
                            address(0),
                            to[i],
                            amount[i],
                            payoutNonce[i]
                        );
                    }
                } else {
                    // Transfer ERC20 tokens
                    try
                        this.safeTransferExternal(
                            IERC20Upgradeable(tokenAddress[i]),
                            to[i],
                            amount[i]
                        )
                    {
                        packPayoutNonce(payoutNonce[i]);
                        emit PayoutSuccessful(
                            tokenAddress[i],
                            to[i],
                            amount[i],
                            payoutNonce[i]
                        );
                    } catch {
                        emit PayoutFailed(
                            tokenAddress[i],
                            to[i],
                            amount[i],
                            payoutNonce[i]
                        );
                    }
                }
            } else {
                emit PayoutFailed(
                    tokenAddress[i],
                    to[i],
                    amount[i],
                    payoutNonce[i]
                );
            }
        }
    }

    /**
     * @dev Sweep the contract balance
     * @param tokenAddress - Address of the token to sweep
     */
    function sweep(address tokenAddress) external nonReentrant {
        if (tokenAddress == address(0)) {
            // Transfer native tokens
            (bool sent, bytes memory data) = owner().call{
                value: address(this).balance
            }("");

            if (!sent) revert SweepFailed(address(0), address(this).balance);
        } else {
            IERC20Upgradeable IERC20Token = IERC20Upgradeable(tokenAddress);
            try
                this.safeTransferExternal(
                    IERC20Token,
                    owner(),
                    IERC20Token.balanceOf(address(this))
                )
            {
                // Transfer ERC20 tokens
            } catch {
                revert SweepFailed(
                    tokenAddress,
                    IERC20Token.balanceOf(address(this))
                );
            }
        }
    }

    /**
     * @dev Cancel a payout nonce
     * @param nonce nonce of the payout
     * @param signature signature of the nonce
     */
    function invalidateNonce(uint64 nonce, bytes memory signature) external {
        // Check if the nonce is valid

        address signer = validateCancelNonce(nonce, signature);

        if (!isApprover(signer)) {
            revert OnlyApprover();
        }

        // Invalidate the nonce
        packPayoutNonce(nonce);
    }

    /**
     * @dev Pause the contract
     */
    function pause() external onlyOwner {
        _pause();
    }

    /**
     * @dev Unpause the contract
     */
    function unpause() external onlyOwner {
        _unpause();
    }

    /**
     * @dev Renounce ownership of the contract
     * @notice This function is overridden to prevent renouncing ownership
     */
    function renounceOwnership() public view override onlyOwner {
        revert CannotRenounceOwnership();
    }

    /**
     * @dev Encode the transaction data for the payroll payout
     * @param to Address to send the funds to
     * @param tokenAddress Address of the token to send
     * @param amount Amount of tokens to send
     * @param payoutNonce Payout nonce to use
     * @return encodedHash Encoded hash of the transaction data
     */
    function encodeTransactionData(
        address to,
        address tokenAddress,
        uint256 amount,
        uint64 payoutNonce
    ) public view returns (bytes32) {
        return
            keccak256(
                abi.encode(owner(), to, tokenAddress, amount, payoutNonce)
            );
    }

    /**
     * @dev Get usage status of a payout nonce
     * @param payoutNonce Payout nonce to check
     * @return Boolean, true for used, false for unused
     */
    function getPayoutNonce(uint256 payoutNonce) public view returns (bool) {
        // Each payout nonce is packed into a uint256, so the index of the uint256 in the array is the payout nonce / 256
        uint256 slotIndex = uint248(payoutNonce >> 8);

        // The bit index of the uint256 is the payout nonce % 256 (0-255)
        uint256 bitIndex = uint8(payoutNonce);

        // If the bit is set, the payout nonce has been used, if not, it has not been used
        return (packedPayoutNonces[slotIndex] & (1 << bitIndex)) != 0;
    }

    /**
     * @dev generate the hash of the payroll transaction
     * @param rootHash hash = hash of the merkle roots signed by the approver
     * @return bytes32 hash
     */
    function generateTransactionHash(
        bytes32 rootHash
    ) public view returns (bytes32) {
        bytes32 digest = keccak256(
            abi.encodePacked(
                bytes1(0x19),
                bytes1(0x01),
                getDomainSeparator(),
                keccak256(abi.encode(PAYROLL_TX_TYPEHASH, rootHash))
            )
        );
        return digest;
    }

    /**
     * @dev generate the hash of the cancel transaction
     * @param nonce nonce of the payout
     * @return bytes32 hash
     */
    function getCancelTransactionHash(
        uint64 nonce
    ) public view returns (bytes32) {
        bytes32 digest = keccak256(
            abi.encodePacked(
                bytes1(0x19),
                bytes1(0x01),
                getDomainSeparator(),
                keccak256(abi.encode(CANCEL_NONCE, nonce))
            )
        );
        return digest;
    }

    /**
     * @dev Set usage status of a payout nonce
     * @param payoutNonce Payout nonce to set
     */
    function packPayoutNonce(uint256 payoutNonce) internal {
        // Packed payout nonces are stored in an array of uint256
        // Each uint256 represents 256 payout nonces

        // Each payout nonce is packed into a uint256, so the index of the uint256 in the array is the payout nonce / 256
        uint256 slot = uint248(payoutNonce >> 8);

        // The bit index of the uint256 is the payout nonce % 256 (0-255)
        uint256 bitIndex = uint8(payoutNonce);

        // Set the bit to 1
        // This means that the payout nonce has been used
        packedPayoutNonces[slot] |= 1 << bitIndex;
    }

    /**
     * @dev This function validates the signature and verifies if signatures are unique and the approver belongs to safe
     * @param roots Address of the token to send
     * @param signatures Amount of tokens to send
     */
    function validateSignatures(
        bytes32[] memory roots,
        bytes[] memory signatures
    ) internal view {
        uint256 rootLength = roots.length;
        // Validate the roots via approver signatures
        address currentApprover;
        for (uint256 i = 0; i < rootLength; ) {
            // Recover signer from the signature
            address signer = validatePayrollTxHashes(roots[i], signatures[i]);
            // Check if the signer is an approver & is different from the current approver
            if (
                signer == SENTINEL_APPROVER ||
                approvers[signer] == address(0) ||
                signer <= currentApprover
            ) revert InvalidPayoutSignature(signatures[i]);

            // Set the current approver to the signer
            currentApprover = signer;

            unchecked {
                i++;
            }
        }
    }

    /**
     * @dev Execute transaction from Gnosis Safe
     * @param tokenAddress Address of the token to send
     * @param amount Amount of tokens to send
     */
    function execTransactionFromGnosis(
        address tokenAddress,
        uint96 amount
    ) internal {
        uint256 contractBalance;
        if (tokenAddress != address(0)) {
            contractBalance = IERC20Upgradeable(tokenAddress).balanceOf(
                address(this)
            );
        } else {
            contractBalance = address(this).balance;
        }

        // If the contract balance is greater than or equal to the required amount, no need to fetch more tokens from safe
        if (contractBalance >= amount) return;

        // Execute payout via allowance module
        // Fetch amount is the difference between the flag token amount to fetch and the current token balance
        IAllowanceModule(ALLOWANCE_MODULE).executeAllowanceTransfer(
            owner(),
            tokenAddress,
            payable(address(this)),
            amount - uint96(contractBalance),
            address(0),
            0,
            address(this),
            bytes("")
        );
    }

    function _authorizeUpgrade(
        address newImplementation
    ) internal override onlyOwner {}

    /**
     * @dev get the domain separator
     * @return bytes32 domain separator
     * @dev - This function is uses cached domain separator when possible to save gas
     */
    function getDomainSeparator() internal view returns (bytes32) {
        if (address(this) == _cachedThis && block.chainid == _cachedChainId) {
            return _cachedDomainSeparator;
        } else {
            return _buildDomainSeparator(address(this));
        }
    }

    /**
     * @dev Build the domain separator
     * @param proxy address of the proxy contract
     * @return bytes32 domain separator
     */
    function _buildDomainSeparator(
        address proxy
    ) internal view returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    EIP712_DOMAIN_TYPEHASH,
                    keccak256(bytes(NAME)),
                    keccak256(bytes(VERSION)),
                    block.chainid,
                    proxy
                )
            );
    }

    /**
     * @dev split the signature into v, r, s
     * @param signature bytes32 signature
     * @return v uint8 v
     * @return r bytes32 r
     * @return s bytes32 s
     */
    function splitSignature(
        bytes memory signature
    ) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
        if (signature.length != 65) revert InvalidSignatureLength();

        assembly {
            // first 32 bytes, after the length prefix
            r := mload(add(signature, 32))
            // second 32 bytes
            s := mload(add(signature, 64))
            // final byte (first byte of the next 32 bytes)
            v := byte(0, mload(add(signature, 96)))
        }
    }

    /**
     * @dev validate the signature of the payroll transaction
     * @param rootHash hash = encodeTransactionData(recipient, tokenAddress, amount, nonce)
     * @param signature signature of the rootHash
     * @return address of the signer
     */
    function validatePayrollTxHashes(
        bytes32 rootHash,
        bytes memory signature
    ) internal view returns (address) {
        uint8 v;
        bytes32 r;
        bytes32 s;

        (v, r, s) = splitSignature(signature);

        bytes32 digest = generateTransactionHash(rootHash);

        if (v > 30) {
            // If v > 30 then default va (27,28) has been adjusted for eth_sign flow
            // To support eth_sign and similar we adjust v
            // and hash the messageHash with the Ethereum message prefix before applying recover
            digest = keccak256(
                abi.encodePacked("\x19Ethereum Signed Message:\n32", digest)
            );
            v -= 4;
        }

        return digest.recover(v, r, s);
    }

    /**
     * @dev validate the signature to cancel nonce
     * @param nonce nonce of the payout
     * @param signature signature of the nonce
     * @return address of the signer
     */
    function validateCancelNonce(
        uint64 nonce,
        bytes memory signature
    ) internal view returns (address) {
        uint8 v;
        bytes32 r;
        bytes32 s;

        (v, r, s) = splitSignature(signature);

        bytes32 digest = getCancelTransactionHash(nonce);

        if (v > 30) {
            // If v > 30 then default va (27,28) has been adjusted for eth_sign flow
            // To support eth_sign and similar we adjust v
            // and hash the messageHash with the Ethereum message prefix before applying recover
            digest = keccak256(
                abi.encodePacked("\x19Ethereum Signed Message:\n32", digest)
            );
            v -= 4;
        }

        return digest.recover(v, r, s);
    }
}

File 2 of 21 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

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

File 3 of 21 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 4 of 21 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 5 of 21 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

File 6 of 21 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

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

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

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

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

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

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

File 7 of 21 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

File 8 of 21 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }

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

File 9 of 21 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

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

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

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

File 10 of 21 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

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

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

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

File 11 of 21 : IERC20Upgradeable.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 IERC20Upgradeable {
    /**
     * @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 12 of 21 : SafeERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.sol";

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

    function safeTransfer(
        IERC20Upgradeable token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20Upgradeable token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20PermitUpgradeable token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 13 of 21 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

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

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../StringsUpgradeable.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 ECDSAUpgradeable {
    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", StringsUpgradeable.toString(s.length), s));
    }

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

File 16 of 21 : MerkleProofUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates merkle trees that are safe
 * against this attack out of the box.
 */
library MerkleProofUpgradeable {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 17 of 21 : MathUpgradeable.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 MathUpgradeable {
    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 18 of 21 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

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

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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 = MathUpgradeable.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, MathUpgradeable.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 20 of 21 : IAllowanceModule.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

interface IAllowanceModule {
    function executeAllowanceTransfer(
        address safe,
        address token,
        address payable to,
        uint96 amount,
        address paymentToken,
        uint96 payment,
        address delegate,
        bytes memory signature
    ) external;
}

File 21 of 21 : ApproverManager.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

// Errors
error DuplicateCallToSetupFunction();
error ThresholdTooHigh(uint256 threshold, uint256 approverCount);
error ThresholdTooLow(uint256 threshold);
error InvalidAddressProvided(address providedAddress);
error DuplicateAddressProvided(address providedAddress);
error ApproverDoesNotExist(address approver);
error ApproverAlreadyExists(address approver);
error OnlyApprover();
error UintOverflow();

/**
 * @title ApproverManager
 * @notice This contract manages the approvers for the Org.
 * @dev This contract is used by the Parcel Payroll contract.
 * @author Sriram Kasyap Meduri - <[email protected]>
 * @author Krishna Kant Sharma - <[email protected]>
 */
contract ApproverManager is OwnableUpgradeable {
    /**
     * @dev Storage layout of the contract.
     *
     *
     */

    /**
     * @dev The name of the contract.
     */
    string public constant NAME = "ParcelPayroll";

    /**
     * @dev The version of the contract.
     */
    string public constant VERSION = "1.0.0";

    /**
     * @dev The sentinel value for the linked list of approvers.
     */
    address internal constant SENTINEL_APPROVER = address(0x1);

    /**
     * @dev The address of the AllowanceModule contract.
     */
    address constant ALLOWANCE_MODULE =
        0xCFbFaC74C26F8647cBDb8c5caf80BB5b32E43134;

    /**
     * @dev Linked list of approvers.
     */
    mapping(address => address) internal approvers;

    /**
     * @dev Number of approvers.
     */
    uint128 internal approverCount;

    /**
     * @dev The threshold of approvers required to approve a payout.
     */
    uint128 public threshold;

    /**
     * @dev The payout nonce is used to prevent replay attacks
     * Each payout nonce is packed into a bit in a uint256. The bit is set to 1 if the nonce has been used and 0 if not.
     * This way, 256 nonces are packed into a single uint256 and stored in the value of packedPayoutNonces mapping.
     * The key of the mapping is the slot number of the payout. Each slot can store 256 nonces.
     * By using mapping, we can access any nonce in constant time.
     **/
    mapping(uint256 => uint256) packedPayoutNonces;

    /**
     * @dev The domain separator used for the EIP-712 signature, cached at initialisation.
     */
    bytes32 _cachedDomainSeparator;

    /**
     * @dev The chain ID of the network, cached at construction.
     */
    uint256 immutable _cachedChainId = block.chainid;

    /**
     * @dev The address of the Org contract, cached at initialisation.
     */
    address _cachedThis;

    /**
     * @dev Storage Gaps to prevent upgrade errors
     */
    uint256[48] __gap;

    /**
     * @dev - Typehash of the EIP712 Domain
     */
    bytes32 internal constant EIP712_DOMAIN_TYPEHASH =
        keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );

    /**
     * @dev - Typehash of the Payroll Transaction
     */
    bytes32 internal constant PAYROLL_TX_TYPEHASH =
        keccak256("PayrollTx(bytes32 rootHash)");

    /**
     * @dev - Typehash of the Nonce Cancelation
     */
    bytes32 internal constant CANCEL_NONCE =
        keccak256("CancelNonce(uint64 nonce)");

    /**
     * @dev Events emitted by the contract.
     *
     *
     */

    /**
     * @dev Emitted when a new approver is added.
     * @param approver The address of the approver added.
     */
    event AddedApprover(address approver);

    /**
     * @dev Emitted when an approver is removed.
     * @param approver The address of the approver removed.
     */
    event RemovedApprover(address approver);

    /**
     * @dev Emitted when the org threshold is changed.
     * @param threshold The new threshold.
     */
    event ChangedThreshold(uint256 threshold);

    /**
     * @dev Approver Management Functions
     *
     *
     */

    /**
     * @notice Adds the approver `approver` to the Org and updates the threshold to `_threshold`.
     * @dev This can only be done via a Org transaction.
     * @param newApprover New approver address.
     * @param _threshold New threshold.
     */
    function addApproverWithThreshold(
        address newApprover,
        uint128 _threshold
    ) public onlyOwner {
        // Approver address cannot be null, the sentinel, the contract or the Org itself.
        if (
            newApprover == address(0) ||
            newApprover == SENTINEL_APPROVER ||
            newApprover == address(this) ||
            newApprover == owner()
        ) revert InvalidAddressProvided(newApprover);

        // No duplicate approvers allowed.
        if (approvers[newApprover] != address(0))
            revert ApproverAlreadyExists(newApprover);

        approvers[newApprover] = approvers[SENTINEL_APPROVER];
        approvers[SENTINEL_APPROVER] = newApprover;
        approverCount++;
        emit AddedApprover(newApprover);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Removes the approver `approver` from the Org and updates the threshold to `_threshold`.
     * @dev This can only be done via a Org transaction.
     * @param prevApprover Approver that pointed to the approver to be removed in the linked list
     * @param approver Approver address to be removed.
     * @param _threshold New threshold.
     */
    function removeApproverWithThreshold(
        address prevApprover,
        address approver,
        uint128 _threshold
    ) public onlyOwner {
        // Only allow to remove an approver, if threshold can still be reached.
        if (approverCount < _threshold)
            revert ThresholdTooHigh(_threshold, approverCount);

        // Validate approver address and check that it corresponds to approver index.
        if (approver == address(0) || approver == SENTINEL_APPROVER)
            revert InvalidAddressProvided(approver);

        if (approvers[prevApprover] != approver)
            revert ApproverDoesNotExist(approver);

        approvers[prevApprover] = approvers[approver];
        delete approvers[approver];
        approverCount--;
        emit RemovedApprover(approver);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Replaces the approver `oldApprover` with `newApprover` in the Org.
     * @dev This can only be done via a Org transaction.
     * @param prevApprover Approver that pointed to the approver to be replaced in the linked list
     * @param oldApprover Approver address to be replaced.
     * @param newApprover New approver address.
     */
    function swapApprover(
        address prevApprover,
        address oldApprover,
        address newApprover
    ) public onlyOwner {
        // Approver address cannot be null, the sentinel or the Org itself.
        if (
            newApprover == address(0) ||
            newApprover == SENTINEL_APPROVER ||
            newApprover == owner() ||
            newApprover == address(this)
        ) revert InvalidAddressProvided(newApprover);

        // No duplicate approvers allowed.
        if (approvers[newApprover] != address(0))
            revert ApproverAlreadyExists(newApprover);

        // Validate oldApprover address and check that it corresponds to approver index.
        if (oldApprover == address(0) || oldApprover == SENTINEL_APPROVER)
            revert InvalidAddressProvided(oldApprover);

        if (approvers[prevApprover] != oldApprover)
            revert ApproverDoesNotExist(oldApprover);

        approvers[newApprover] = approvers[oldApprover];
        approvers[prevApprover] = newApprover;
        delete approvers[oldApprover];
        emit RemovedApprover(oldApprover);
        emit AddedApprover(newApprover);
    }

    /**
     * @notice Changes the threshold of the Org to `_threshold`.
     * @dev This can only be done via a Org transaction.
     * @param _threshold New threshold.
     */
    function changeThreshold(uint128 _threshold) public onlyOwner {
        // Validate that threshold is less than or equal to the number of approvers.
        if (_threshold > approverCount)
            revert ThresholdTooHigh(_threshold, approverCount);

        // There has to be at least one Org approver.
        if (_threshold == 0) revert ThresholdTooLow(_threshold);

        threshold = _threshold;
        emit ChangedThreshold(threshold);
    }

    /**
     * @notice Returns if `approver` is an approver of the Org.
     * @return Boolean if approver is an approver of the Org.
     */
    function isApprover(address approver) public view returns (bool) {
        return
            approver != SENTINEL_APPROVER && approvers[approver] != address(0);
    }

    /**
     * @notice Returns a list of Org approvers.
     * @return Array of Org approvers.
     */
    function getApprovers() public view returns (address[] memory) {
        address[] memory array = new address[](approverCount);

        // populate return array
        uint256 index = 0;
        address currentApprover = approvers[SENTINEL_APPROVER];
        while (currentApprover != SENTINEL_APPROVER) {
            array[index] = currentApprover;
            currentApprover = approvers[currentApprover];
            index++;
        }
        return array;
    }

    /**
     * @notice Sets the initial storage of the contract.
     * @param _approvers List of Org approvers.
     * @param _threshold Number of required confirmations for a Org transaction.
     */
    function setupApprovers(
        address[] calldata _approvers,
        uint128 _threshold
    ) internal {
        uint256 _approverLength = _approvers.length;
        // Threshold can only be 0 at initialization.
        // Check ensures that setup function can only be called once.
        if (threshold != 0) revert DuplicateCallToSetupFunction();
        // Validate that threshold is less than or equal to number of added approvers.
        if (_threshold > _approverLength)
            revert ThresholdTooHigh(_threshold, _approverLength);
        // There has to be at least one Org approver.
        if (_threshold < 1) revert ThresholdTooLow(_threshold);
        // Initializing Org approvers.
        address currentApprover = SENTINEL_APPROVER;
        for (uint256 i = 0; i < _approverLength; i++) {
            // Approver address cannot be null.
            address approver = _approvers[i];
            if (
                approver == address(0) ||
                approver == SENTINEL_APPROVER ||
                approver == address(this) ||
                approver == owner()
            ) revert InvalidAddressProvided(approver);

            if (
                currentApprover == approver || approvers[approver] != address(0)
            ) revert DuplicateAddressProvided(approver);

            approvers[currentApprover] = approver;
            currentApprover = approver;
        }
        approvers[currentApprover] = SENTINEL_APPROVER;
        approverCount = uint128(_approverLength);
        threshold = _threshold;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 100
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ApproverAlreadyExists","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ApproverDoesNotExist","type":"error"},{"inputs":[],"name":"CannotRenounceOwnership","type":"error"},{"inputs":[{"internalType":"address","name":"providedAddress","type":"address"}],"name":"DuplicateAddressProvided","type":"error"},{"inputs":[],"name":"DuplicateCallToSetupFunction","type":"error"},{"inputs":[{"internalType":"address","name":"providedAddress","type":"address"}],"name":"InvalidAddressProvided","type":"error"},{"inputs":[{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"InvalidPayoutSignature","type":"error"},{"inputs":[],"name":"InvalidSignatureLength","type":"error"},{"inputs":[],"name":"OnlyApprover","type":"error"},{"inputs":[{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"PayoutNonceAlreadyExecuted","type":"error"},{"inputs":[],"name":"PayrollDataLengthMismatch","type":"error"},{"inputs":[],"name":"RootSignatureLengthMismatch","type":"error"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SweepFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"threshold","type":"uint256"},{"internalType":"uint256","name":"approverCount","type":"uint256"}],"name":"ThresholdTooHigh","type":"error"},{"inputs":[{"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"ThresholdTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"tokenAddress1","type":"address"},{"internalType":"address","name":"tokenAddress2","type":"address"}],"name":"TokensNotSorted","type":"error"},{"inputs":[],"name":"UnauthorizedTransfer","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"approver","type":"address"}],"name":"AddedApprover","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"ChangedThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"orgAddress","type":"address"},{"indexed":true,"internalType":"address[]","name":"approvers","type":"address[]"},{"indexed":false,"internalType":"uint128","name":"approvalsRequired","type":"uint128"}],"name":"OrgSetup","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payoutNonce","type":"uint256"}],"name":"PayoutFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payoutNonce","type":"uint256"}],"name":"PayoutSuccessful","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"approver","type":"address"}],"name":"RemovedApprover","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newApprover","type":"address"},{"internalType":"uint128","name":"_threshold","type":"uint128"}],"name":"addApproverWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_threshold","type":"uint128"}],"name":"changeThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint64","name":"payoutNonce","type":"uint64"}],"name":"encodeTransactionData","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"address[]","name":"tokenAddress","type":"address[]"},{"internalType":"uint128[]","name":"amount","type":"uint128[]"},{"internalType":"uint64[]","name":"payoutNonce","type":"uint64[]"},{"internalType":"bytes32[][][]","name":"proof","type":"bytes32[][][]"},{"internalType":"bytes32[]","name":"roots","type":"bytes32[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"executePayroll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"rootHash","type":"bytes32"}],"name":"generateTransactionHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getApprovers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"getCancelTransactionHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"payoutNonce","type":"uint256"}],"name":"getPayoutNonce","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"safeAddress","type":"address"},{"internalType":"address[]","name":"_approvers","type":"address[]"},{"internalType":"uint128","name":"approvalsRequired","type":"uint128"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"invalidateNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"isApprover","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"prevApprover","type":"address"},{"internalType":"address","name":"approver","type":"address"},{"internalType":"uint128","name":"_threshold","type":"uint128"}],"name":"removeApproverWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20Upgradeable","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"safeTransferExternal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"prevApprover","type":"address"},{"internalType":"address","name":"oldApprover","type":"address"},{"internalType":"address","name":"newApprover","type":"address"}],"name":"swapApprover","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"threshold","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60c0604052306080524660a0523480156200001957600080fd5b50620000246200002a565b620000ec565b600054610100900460ff1615620000975760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000ea576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b60805160a051613dea6200012e60003960006121ac01526000818161095e0152818161099e01528181610a3501528181610a750152610af10152613dea6000f3fe6080604052600436106101705760003560e01c80638d878803116100cc578063e37bd0a11161007a578063e37bd0a11461041f578063e3f1b42e1461043f578063f07439de1461045f578063f2fde38b1461047f578063f7c3ff821461049f578063fec2c104146104bf578063ffa1ad741461050057600080fd5b80638d878803146103175780638da5cb5b1461033757806390f2aca414610359578063a3f4df7e14610379578063aa0690f8146103bf578063cf89959a146103df578063db0463ba146103ff57600080fd5b806352d1902d1161012957806352d1902d146102445780635c975abb146102675780636cb3e8ef1461028b5780636d218e48146102ad578063715018a6146102cd5780638456cb59146102e257806388fd0941146102f757600080fd5b806301681a621461017c578063126e704e1461019e5780633659cfe6146101be5780633f4ba83a146101de57806342cde4e8146101f35780634f1ef2861461023157600080fd5b3661017757005b600080fd5b34801561018857600080fd5b5061019c610197366004613156565b610531565b005b3480156101aa57600080fd5b5061019c6101b9366004613173565b610753565b3480156101ca57600080fd5b5061019c6101d9366004613156565b610954565b3480156101ea57600080fd5b5061019c610a19565b3480156101ff57600080fd5b5061012e5461021b90600160801b90046001600160801b031681565b60405161022891906131be565b60405180910390f35b61019c61023f366004613287565b610a2b565b34801561025057600080fd5b50610259610ae4565b604051908152602001610228565b34801561027357600080fd5b5060fb5460ff165b6040519015158152602001610228565b34801561029757600080fd5b506102a0610b92565b60405161022891906132d6565b3480156102b957600080fd5b5061027b6102c8366004613156565b610c90565b3480156102d957600080fd5b5061019c610ccc565b3480156102ee57600080fd5b5061019c610ced565b34801561030357600080fd5b50610259610312366004613323565b610cfd565b34801561032357600080fd5b5061019c610332366004613358565b610da7565b34801561034357600080fd5b5061034c610f59565b60405161022891906133f0565b34801561036557600080fd5b5061019c610374366004613404565b610f68565b34801561038557600080fd5b506103b26040518060400160405280600d81526020016c14185c98d95b14185e5c9bdb1b609a1b81525081565b604051610228919061349b565b3480156103cb57600080fd5b5061019c6103da3660046134ae565b61111c565b3480156103eb57600080fd5b5061019c6103fa3660046134fa565b6112cf565b34801561040b57600080fd5b5061019c61041a366004613516565b611331565b34801561042b57600080fd5b5061019c61043a366004613557565b611365565b34801561044b57600080fd5b5061025961045a366004613572565b611444565b34801561046b57600080fd5b5061019c61047a3660046138df565b6114ae565b34801561048b57600080fd5b5061019c61049a366004613156565b611dec565b3480156104ab57600080fd5b506102596104ba3660046139f9565b611e62565b3480156104cb57600080fd5b5061027b6104da366004613323565b600881901c600090815261012f6020526040902054600160ff9092169190911b16151590565b34801561050c57600080fd5b506103b2604051806040016040528060058152602001640312e302e360dc1b81525081565b610539611eba565b6001600160a01b0381166105d957600080610552610f59565b6001600160a01b03164760405160006040518083038185875af1925050503d806000811461059c576040519150601f19603f3d011682016040523d82523d6000602084013e6105a1565b606091505b5091509150816105d257600047604051633a69abdb60e11b81526004016105c9929190613a14565b60405180910390fd5b5050610746565b803063db0463ba826105e9610f59565b6040516370a0823160e01b81526001600160a01b038616906370a08231906106159030906004016133f0565b602060405180830381865afa158015610632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106569190613a2d565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156106a557600080fd5b505af19250505080156106b6575060015b610744576040516370a0823160e01b815282906001600160a01b038316906370a08231906106e89030906004016133f0565b602060405180830381865afa158015610705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107299190613a2d565b604051633a69abdb60e11b81526004016105c9929190613a14565b505b610750600160c955565b50565b61075b611f1a565b6001600160a01b038116158061077a57506001600160a01b0381166001145b8061079d5750610788610f59565b6001600160a01b0316816001600160a01b0316145b806107b057506001600160a01b03811630145b156107d05780604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03818116600090815261012d6020526040902054161561080c5780604051632737ac7360e21b81526004016105c991906133f0565b6001600160a01b038216158061082b57506001600160a01b0382166001145b1561084b5781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03838116600090815261012d602052604090205481169083161461088b5781604051634f837c9960e01b81526004016105c991906133f0565b6001600160a01b03828116600081815261012d6020526040808220805486861680855283852080549288166001600160a01b03199384161790559589168452828420805482169096179095559290915281549092169055517f472cdd2f96ec512031842f7b11dd147ccbaa8767632d56b03038107f6fff9796906109109084906133f0565b60405180910390a17f7a475319b7eb5c5d3a6cc47a1db186497523ad8fcaf49406b6dfd0c8af58592c8160405161094791906133f0565b60405180910390a1505050565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016300361099c5760405162461bcd60e51b81526004016105c990613a46565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166109ce611f79565b6001600160a01b0316146109f45760405162461bcd60e51b81526004016105c990613a92565b6109fd81611f95565b6040805160008082526020820190925261075091839190611f9d565b610a21611f1a565b610a29612108565b565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610a735760405162461bcd60e51b81526004016105c990613a46565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610aa5611f79565b6001600160a01b031614610acb5760405162461bcd60e51b81526004016105c990613a92565b610ad482611f95565b610ae082826001611f9d565b5050565b6000306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610b7f5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016105c9565b50600080516020613d6e83398151915290565b61012e546060906000906001600160801b03166001600160401b03811115610bbc57610bbc6131d2565b604051908082528060200260200182016040528015610be5578160200160208202803683370190505b506001600090815261012d6020527fe278171178ecf2583e4e9c73c9a18d3ff0f6142f8f9926be1eba7c0b61591f5054919250906001600160a01b03165b6001600160a01b038116600114610c885780838381518110610c4757610c47613ade565b6001600160a01b03928316602091820292909201810191909152918116600090815261012d9092526040909120541681610c8081613b0a565b925050610c23565b509092915050565b60006001600160a01b038216600114801590610cc657506001600160a01b03828116600090815261012d60205260409020541615155b92915050565b610cd4611f1a565b6040516377aeb0ad60e01b815260040160405180910390fd5b610cf5611f1a565b610a29612154565b600080601960f81b600160f81b610d12612191565b604080517f8fba187ae9ab8a9763f7172f9bfd506ee0dfef805deabfbabbb76e3a3c44804d60208201529081018790526060015b60408051808303601f190181529082905280516020918201206001600160f81b0319958616918301919091529290931660218401526022830152604282015260620160408051601f1981840301815291905280516020909101209392505050565b600054610100900460ff1615808015610dc75750600054600160ff909116105b80610de15750303b158015610de1575060005460ff166001145b610e445760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105c9565b6000805460ff191660011790558015610e67576000805461ff0019166101001790555b610e70856121e9565b610e7861223b565b610e8061226a565b610e88612299565b610e91306122c0565b6101305561013180546001600160a01b03191630179055610eb38484846123a3565b8383604051610ec3929190613b23565b6040518091039020856001600160a01b03167f85d93ec6e0feb0e3c2795fce5f86652db8f93cc41d48e40e409007cd365cea7984604051610f0491906131be565b60405180910390a38015610f52576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6097546001600160a01b031690565b610f70611f1a565b61012e546001600160801b0380831691161015610fb85761012e546040516313c3d1b160e01b81526001600160801b03808416600483015290911660248201526044016105c9565b6001600160a01b0382161580610fd757506001600160a01b0382166001145b15610ff75781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03838116600090815261012d60205260409020548116908316146110375781604051634f837c9960e01b81526004016105c991906133f0565b6001600160a01b03828116600081815261012d6020526040808220805488861684529183208054929095166001600160a01b031992831617909455918152825490911690915561012e80546001600160801b03169161109583613b65565b91906101000a8154816001600160801b0302191690836001600160801b03160217905550507f472cdd2f96ec512031842f7b11dd147ccbaa8767632d56b03038107f6fff9796826040516110e991906133f0565b60405180910390a161012e546001600160801b03828116600160801b90920416146111175761111781611365565b505050565b611124611f1a565b6001600160a01b038216158061114357506001600160a01b0382166001145b8061115657506001600160a01b03821630145b806111795750611164610f59565b6001600160a01b0316826001600160a01b0316145b156111995781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03828116600090815261012d602052604090205416156111d55781604051632737ac7360e21b81526004016105c991906133f0565b61012d6020527fe278171178ecf2583e4e9c73c9a18d3ff0f6142f8f9926be1eba7c0b61591f5080546001600160a01b038481166000818152604081208054939094166001600160a01b0319938416179093556001835283549091161790915561012e80546001600160801b03169161124d83613b88565b91906101000a8154816001600160801b0302191690836001600160801b03160217905550507f7a475319b7eb5c5d3a6cc47a1db186497523ad8fcaf49406b6dfd0c8af58592c826040516112a191906133f0565b60405180910390a161012e546001600160801b03828116600160801b9092041614610ae057610ae081611365565b60006112db83836125ce565b90506112e681610c90565b61130357604051635ce18fa560e01b815260040160405180910390fd5b66ffffffffffffff600884901c16600090815261012f602052604090208054600160ff86161b179055505050565b333014611351576040516325cdf54f60e21b815260040160405180910390fd5b6111176001600160a01b038416838361266f565b61136d611f1a565b61012e546001600160801b0390811690821611156113b65761012e546040516313c3d1b160e01b81526001600160801b03808416600483015290911660248201526044016105c9565b806001600160801b03166000036113e257806040516309f9112f60e01b81526004016105c991906131be565b61012e80546001600160801b03808416600160801b90810292821692909217928390556040517f610f7ff2b304ae8903c3de74c60c6ab1f7d6226b3f52c5161905bb5ad4039c9393611439939004909116906131be565b60405180910390a150565b600061144e610f59565b604080516001600160a01b039283166020820152828816918101919091529085166060820152608081018490526001600160401b03831660a082015260c0016040516020818303038152906040528051906020012090505b949350505050565b6114b6611eba565b6114be6126c5565b8651825160006001600160801b0383166001600160401b038111156114e5576114e56131d2565b60405190808252806020026020018201604052801561150e578160200160208202803683370190505b5090506001600160801b038316158061153157508851836001600160801b031614155b8061154657508751836001600160801b031614155b8061155b57508651836001600160801b031614155b1561157957604051630f36b20960e31b815260040160405180910390fd5b8351826001600160801b0316146115a35760405163706251a560e11b815260040160405180910390fd5b6115ad858561270b565b6000808a6000815181106115c3576115c3613ade565b6020026020010151905060005b856001600160801b03168110156119005761162d8a82815181106115f6576115f6613ade565b60200260200101516001600160401b0316600881901c600090815261012f6020526040902054600160ff9092169190911b16151590565b156116755789818151811061164457611644613ade565b602002602001015160405163e06a2eb760e01b81526004016105c991906001600160401b0391909116815260200190565b60006116f08e838151811061168c5761168c613ade565b60200260200101518e84815181106116a6576116a6613ade565b60200260200101518e85815181106116c0576116c0613ade565b60200260200101516001600160801b03168e86815181106116e3576116e3613ade565b6020026020010151611444565b90506000805b876001600160801b031681108015611720575061012e54600160801b90046001600160801b031682105b1561179e5761177b8c858151811061173a5761173a613ade565b6020026020010151828151811061175357611753613ade565b60200260200101518c838151811061176d5761176d613ade565b6020026020010151856127ea565b1561178c5761178982613b0a565b91505b8061179681613b0a565b9150506116f6565b5061012e54600160801b90046001600160801b031681106118eb5760018684815181106117cd576117cd613ade565b6020026020010190151590811515815250508d83815181106117f1576117f1613ade565b60200260200101516001600160a01b0316846001600160a01b0316146118ba578d838151811061182357611823613ade565b60200260200101516001600160a01b0316846001600160a01b0316111561188f57838e848151811061185757611857613ade565b6020026020010151604051632a60df1960e21b81526004016105c99291906001600160a01b0392831681529116602082015260400190565b6118998486612802565b8d83815181106118ab576118ab613ade565b60200260200101519350600094505b8c83815181106118cc576118cc613ade565b60200260200101516001600160801b0316856118e89190613bb6565b94505b505080806118f890613b0a565b9150506115d0565b508115611911576119118183612802565b505060005b836001600160801b0316811015611dd55781818151811061193957611939613ade565b6020026020010151801561195f575061195d8882815181106115f6576115f6613ade565b155b15611d335760006001600160a01b03168a828151811061198157611981613ade565b60200260200101516001600160a01b031603611b8a576000808c83815181106119ac576119ac613ade565b60200260200101516001600160a01b03168b84815181106119cf576119cf613ade565b60200260200101516001600160801b031660405160006040518083038185875af1925050503d8060008114611a20576040519150601f19603f3d011682016040523d82523d6000602084013e611a25565b606091505b509150915081611aab57600080516020613d4e83398151915260008e8581518110611a5257611a52613ade565b60200260200101518d8681518110611a6c57611a6c613ade565b60200260200101518d8781518110611a8657611a86613ade565b6020026020010151604051611a9e9493929190613bc9565b60405180910390a1611b83565b611af98a8481518110611ac057611ac0613ade565b60200260200101516001600160401b0316600881901c600090815261012f602052604090208054600160ff9093169290921b9091179055565b7fa0f991c2037f4be751314d611d7eb492af2256346379f5213899f5d7651d025560008e8581518110611b2e57611b2e613ade565b60200260200101518d8681518110611b4857611b48613ade565b60200260200101518d8781518110611b6257611b62613ade565b6020026020010151604051611b7a9493929190613bc9565b60405180910390a15b5050611dc3565b306001600160a01b031663db0463ba8b8381518110611bab57611bab613ade565b60200260200101518d8481518110611bc557611bc5613ade565b60200260200101518c8581518110611bdf57611bdf613ade565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b03166044820152606401600060405180830381600087803b158015611c4257600080fd5b505af1925050508015611c53575060015b611ceb57600080516020613d4e8339815191528a8281518110611c7857611c78613ade565b60200260200101518c8381518110611c9257611c92613ade565b60200260200101518b8481518110611cac57611cac613ade565b60200260200101518b8581518110611cc657611cc6613ade565b6020026020010151604051611cde9493929190613bc9565b60405180910390a1611dc3565b611d00888281518110611ac057611ac0613ade565b7fa0f991c2037f4be751314d611d7eb492af2256346379f5213899f5d7651d02558a8281518110611c7857611c78613ade565b600080516020613d4e8339815191528a8281518110611d5457611d54613ade565b60200260200101518c8381518110611d6e57611d6e613ade565b60200260200101518b8481518110611d8857611d88613ade565b60200260200101518b8581518110611da257611da2613ade565b6020026020010151604051611dba9493929190613bc9565b60405180910390a15b80611dcd81613b0a565b915050611916565b50505050611de3600160c955565b50505050505050565b611df4611f1a565b6001600160a01b038116611e595760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105c9565b610750816121e9565b600080601960f81b600160f81b611e77612191565b604080517ff34b6449ec77bb4eafd875362be8394d87386afd5afa428225a2e7c45bfeea5760208201526001600160401b03881691810191909152606001610d46565b600260c95403611f0c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105c9565b600260c955565b600160c955565b33611f23610f59565b6001600160a01b031614610a295760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c9565b600080516020613d6e833981519152546001600160a01b031690565b610750611f1a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611fd05761111783612932565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561202a575060408051601f3d908101601f1916820190925261202791810190613a2d565b60015b61208d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016105c9565b600080516020613d6e83398151915281146120fc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016105c9565b506111178383836129ce565b6121106129f9565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161214a91906133f0565b60405180910390a1565b61215c6126c5565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861213d3390565b610131546000906001600160a01b0316301480156121ce57507f000000000000000000000000000000000000000000000000000000000000000046145b156121db57506101305490565b6121e4306122c0565b905090565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122625760405162461bcd60e51b81526004016105c990613c03565b610a29612a42565b600054610100900460ff166122915760405162461bcd60e51b81526004016105c990613c03565b610a29612a75565b600054610100900460ff16610a295760405162461bcd60e51b81526004016105c990613c03565b604080518082018252600d81526c14185c98d95b14185e5c9bdb1b609a1b6020918201528151808301835260058152640312e302e360dc1b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527fed6e05651bd8011561b6b77e8887c7ee896d57d73bc8cb9896dd9cd314e7808d818401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608201524660808201526001600160a01b039390931660a0808501919091528251808503909101815260c0909301909152815191012090565b61012e548290600160801b90046001600160801b0316156123d65760405162014d5560e71b815260040160405180910390fd5b80826001600160801b03161115612412576040516313c3d1b160e01b81526001600160801b0383166004820152602481018290526044016105c9565b6001826001600160801b0316101561243f57816040516309f9112f60e01b81526004016105c991906131be565b600160005b8281101561258857600086868381811061246057612460613ade565b90506020020160208101906124759190613156565b90506001600160a01b038116158061249657506001600160a01b0381166001145b806124a957506001600160a01b03811630145b806124cc57506124b7610f59565b6001600160a01b0316816001600160a01b0316145b156124ec5780604051634369193560e01b81526004016105c991906133f0565b806001600160a01b0316836001600160a01b0316148061252657506001600160a01b03818116600090815261012d60205260409020541615155b15612546578060405163f91658a960e01b81526004016105c991906133f0565b6001600160a01b03928316600090815261012d6020526040902080546001600160a01b031916938216939093179092558061258081613b0a565b915050612444565b506001600160a01b0316600090815261012d6020526040902080546001600160a01b03191660011790556001600160801b03918216600160801b0291161761012e555050565b6000806000806125dd85612a9c565b9194509250905060006125ef87611e62565b9050601e8460ff161115612658576040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052605c016040516020818303038152906040528051906020012090506004846126559190613c4e565b93505b61266481858585612adf565b979650505050505050565b6111178363a9059cbb60e01b848460405160240161268e929190613a14565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612b07565b60fb5460ff1615610a295760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016105c9565b81516000805b82811015610f5257600061275786838151811061273057612730613ade565b602002602001015186848151811061274a5761274a613ade565b6020026020010151612bd9565b90506001600160a01b0381166001148061278a57506001600160a01b03818116600090815261012d602052604090205416155b806127a75750826001600160a01b0316816001600160a01b031611155b156127e0578482815181106127be576127be613ade565b6020026020010151604051634ad00be960e11b81526004016105c9919061349b565b9150600101612711565b6000826127f78584612bfa565b1490505b9392505050565b60006001600160a01b03831615612887576040516370a0823160e01b81526001600160a01b038416906370a082319061283f9030906004016133f0565b602060405180830381865afa15801561285c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128809190613a2d565b905061288a565b50475b816001600160601b0316811061289f57505050565b73cfbfac74c26f8647cbdb8c5caf80bb5b32e43134634515641a6128c1610f59565b85306128cd8688613c67565b60008030604051806020016040528060008152506040518963ffffffff1660e01b8152600401612904989796959493929190613c8e565b600060405180830381600087803b15801561291e57600080fd5b505af1158015611de3573d6000803e3d6000fd5b6001600160a01b0381163b61299f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016105c9565b600080516020613d6e83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6129d783612c47565b6000825111806129e45750805b15611117576129f38383612c87565b50505050565b60fb5460ff16610a295760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105c9565b600054610100900460ff16612a695760405162461bcd60e51b81526004016105c990613c03565b60fb805460ff19169055565b600054610100900460ff16611f135760405162461bcd60e51b81526004016105c990613c03565b60008060008351604114612ac357604051634be6321b60e01b815260040160405180910390fd5b5050506020810151604082015160609092015160001a92909190565b6000806000612af087878787612d7b565b91509150612afd81612e35565b5095945050505050565b6000612b5c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612f7a9092919063ffffffff16565b8051909150156111175780806020019051810190612b7a9190613cf9565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c9565b600080600080612be885612a9c565b9194509250905060006125ef87610cfd565b600081815b8451811015612c3f57612c2b82868381518110612c1e57612c1e613ade565b6020026020010151612f89565b915080612c3781613b0a565b915050612bff565b509392505050565b612c5081612932565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b612cef5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105c9565b600080846001600160a01b031684604051612d0a9190613d1b565b600060405180830381855af49150503d8060008114612d45576040519150601f19603f3d011682016040523d82523d6000602084013e612d4a565b606091505b5091509150612d728282604051806060016040528060278152602001613d8e60279139612fb5565b95945050505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115612da85750600090506003612e2c565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612dfc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612e2557600060019250925050612e2c565b9150600090505b94509492505050565b6000816004811115612e4957612e49613d37565b03612e515750565b6001816004811115612e6557612e65613d37565b03612ead5760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b60448201526064016105c9565b6002816004811115612ec157612ec1613d37565b03612f0e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105c9565b6003816004811115612f2257612f22613d37565b036107505760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016105c9565b60606114a68484600085612fce565b6000818310612fa55760008281526020849052604090206127fb565b5060009182526020526040902090565b60608315612fc45750816127fb565b6127fb838361309e565b60608247101561302f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c9565b600080866001600160a01b0316858760405161304b9190613d1b565b60006040518083038185875af1925050503d8060008114613088576040519150601f19603f3d011682016040523d82523d6000602084013e61308d565b606091505b5091509150612664878383876130c8565b8151156130ae5781518083602001fd5b8060405162461bcd60e51b81526004016105c9919061349b565b60608315613137578251600003613130576001600160a01b0385163b6131305760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c9565b50816114a6565b6114a6838361309e565b6001600160a01b038116811461075057600080fd5b60006020828403121561316857600080fd5b81356127fb81613141565b60008060006060848603121561318857600080fd5b833561319381613141565b925060208401356131a381613141565b915060408401356131b381613141565b809150509250925092565b6001600160801b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613210576132106131d2565b604052919050565b600082601f83011261322957600080fd5b81356001600160401b03811115613242576132426131d2565b613255601f8201601f19166020016131e8565b81815284602083860101111561326a57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806040838503121561329a57600080fd5b82356132a581613141565b915060208301356001600160401b038111156132c057600080fd5b6132cc85828601613218565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156133175783516001600160a01b0316835292840192918401916001016132f2565b50909695505050505050565b60006020828403121561333557600080fd5b5035919050565b80356001600160801b038116811461335357600080fd5b919050565b6000806000806060858703121561336e57600080fd5b843561337981613141565b935060208501356001600160401b038082111561339557600080fd5b818701915087601f8301126133a957600080fd5b8135818111156133b857600080fd5b8860208260051b85010111156133cd57600080fd5b6020830195508094505050506133e56040860161333c565b905092959194509250565b6001600160a01b0391909116815260200190565b60008060006060848603121561341957600080fd5b833561342481613141565b9250602084013561343481613141565b91506134426040850161333c565b90509250925092565b60005b8381101561346657818101518382015260200161344e565b50506000910152565b6000815180845261348781602086016020860161344b565b601f01601f19169290920160200192915050565b6020815260006127fb602083018461346f565b600080604083850312156134c157600080fd5b82356134cc81613141565b91506134da6020840161333c565b90509250929050565b80356001600160401b038116811461335357600080fd5b6000806040838503121561350d57600080fd5b6132a5836134e3565b60008060006060848603121561352b57600080fd5b833561353681613141565b9250602084013561354681613141565b929592945050506040919091013590565b60006020828403121561356957600080fd5b6127fb8261333c565b6000806000806080858703121561358857600080fd5b843561359381613141565b935060208501356135a381613141565b9250604085013591506133e5606086016134e3565b60006001600160401b038211156135d1576135d16131d2565b5060051b60200190565b600082601f8301126135ec57600080fd5b813560206136016135fc836135b8565b6131e8565b82815260059290921b8401810191818101908684111561362057600080fd5b8286015b8481101561364457803561363781613141565b8352918301918301613624565b509695505050505050565b600082601f83011261366057600080fd5b813560206136706135fc836135b8565b82815260059290921b8401810191818101908684111561368f57600080fd5b8286015b84811015613644576136a48161333c565b8352918301918301613693565b600082601f8301126136c257600080fd5b813560206136d26135fc836135b8565b82815260059290921b840181019181810190868411156136f157600080fd5b8286015b8481101561364457613706816134e3565b83529183019183016136f5565b600082601f83011261372457600080fd5b813560206137346135fc836135b8565b82815260059290921b8401810191818101908684111561375357600080fd5b8286015b848110156136445780358352918301918301613757565b600082601f83011261377f57600080fd5b8135602061378f6135fc836135b8565b82815260059290921b840181019181810190868411156137ae57600080fd5b8286015b848110156136445780356001600160401b03808211156137d157600080fd5b818901915089603f8301126137e557600080fd5b858201356137f56135fc826135b8565b81815260059190911b830160400190878101908c83111561381557600080fd5b604085015b8381101561384e5780358581111561383157600080fd5b6138408f6040838a0101613713565b84525091890191890161381a565b508752505050928401925083016137b2565b600082601f83011261387157600080fd5b813560206138816135fc836135b8565b82815260059290921b840181019181810190868411156138a057600080fd5b8286015b848110156136445780356001600160401b038111156138c35760008081fd5b6138d18986838b0101613218565b8452509183019183016138a4565b600080600080600080600060e0888a0312156138fa57600080fd5b87356001600160401b038082111561391157600080fd5b61391d8b838c016135db565b985060208a013591508082111561393357600080fd5b61393f8b838c016135db565b975060408a013591508082111561395557600080fd5b6139618b838c0161364f565b965060608a013591508082111561397757600080fd5b6139838b838c016136b1565b955060808a013591508082111561399957600080fd5b6139a58b838c0161376e565b945060a08a01359150808211156139bb57600080fd5b6139c78b838c01613713565b935060c08a01359150808211156139dd57600080fd5b506139ea8a828b01613860565b91505092959891949750929550565b600060208284031215613a0b57600080fd5b6127fb826134e3565b6001600160a01b03929092168252602082015260400190565b600060208284031215613a3f57600080fd5b5051919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613b1c57613b1c613af4565b5060010190565b60008184825b85811015613b5a578135613b3c81613141565b6001600160a01b031683526020928301929190910190600101613b29565b509095945050505050565b60006001600160801b03821680613b7e57613b7e613af4565b6000190192915050565b60006001600160801b038281166002600160801b03198101613bac57613bac613af4565b6001019392505050565b80820180821115610cc657610cc6613af4565b6001600160a01b0394851681529290931660208301526001600160801b031660408201526001600160401b03909116606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60ff8281168282160390811115610cc657610cc6613af4565b6001600160601b03828116828216039080821115613c8757613c87613af4565b5092915050565b6001600160a01b038981168252888116602083015287811660408301526001600160601b0387811660608401528682166080840152851660a0830152831660c082015261010060e08201819052600090613cea8382018561346f565b9b9a5050505050505050505050565b600060208284031215613d0b57600080fd5b815180151581146127fb57600080fd5b60008251613d2d81846020870161344b565b9190910192915050565b634e487b7160e01b600052602160045260246000fdfe9466bd35fd7a18365ae41c835165ccc25ee9e2c96dccb8d232729fccfd678082360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c15dc0def9dd4c1d4df8790dfebead2cf5f6ac61213d8ec38f837271861091a164736f6c63430008110033

Deployed Bytecode

0x6080604052600436106101705760003560e01c80638d878803116100cc578063e37bd0a11161007a578063e37bd0a11461041f578063e3f1b42e1461043f578063f07439de1461045f578063f2fde38b1461047f578063f7c3ff821461049f578063fec2c104146104bf578063ffa1ad741461050057600080fd5b80638d878803146103175780638da5cb5b1461033757806390f2aca414610359578063a3f4df7e14610379578063aa0690f8146103bf578063cf89959a146103df578063db0463ba146103ff57600080fd5b806352d1902d1161012957806352d1902d146102445780635c975abb146102675780636cb3e8ef1461028b5780636d218e48146102ad578063715018a6146102cd5780638456cb59146102e257806388fd0941146102f757600080fd5b806301681a621461017c578063126e704e1461019e5780633659cfe6146101be5780633f4ba83a146101de57806342cde4e8146101f35780634f1ef2861461023157600080fd5b3661017757005b600080fd5b34801561018857600080fd5b5061019c610197366004613156565b610531565b005b3480156101aa57600080fd5b5061019c6101b9366004613173565b610753565b3480156101ca57600080fd5b5061019c6101d9366004613156565b610954565b3480156101ea57600080fd5b5061019c610a19565b3480156101ff57600080fd5b5061012e5461021b90600160801b90046001600160801b031681565b60405161022891906131be565b60405180910390f35b61019c61023f366004613287565b610a2b565b34801561025057600080fd5b50610259610ae4565b604051908152602001610228565b34801561027357600080fd5b5060fb5460ff165b6040519015158152602001610228565b34801561029757600080fd5b506102a0610b92565b60405161022891906132d6565b3480156102b957600080fd5b5061027b6102c8366004613156565b610c90565b3480156102d957600080fd5b5061019c610ccc565b3480156102ee57600080fd5b5061019c610ced565b34801561030357600080fd5b50610259610312366004613323565b610cfd565b34801561032357600080fd5b5061019c610332366004613358565b610da7565b34801561034357600080fd5b5061034c610f59565b60405161022891906133f0565b34801561036557600080fd5b5061019c610374366004613404565b610f68565b34801561038557600080fd5b506103b26040518060400160405280600d81526020016c14185c98d95b14185e5c9bdb1b609a1b81525081565b604051610228919061349b565b3480156103cb57600080fd5b5061019c6103da3660046134ae565b61111c565b3480156103eb57600080fd5b5061019c6103fa3660046134fa565b6112cf565b34801561040b57600080fd5b5061019c61041a366004613516565b611331565b34801561042b57600080fd5b5061019c61043a366004613557565b611365565b34801561044b57600080fd5b5061025961045a366004613572565b611444565b34801561046b57600080fd5b5061019c61047a3660046138df565b6114ae565b34801561048b57600080fd5b5061019c61049a366004613156565b611dec565b3480156104ab57600080fd5b506102596104ba3660046139f9565b611e62565b3480156104cb57600080fd5b5061027b6104da366004613323565b600881901c600090815261012f6020526040902054600160ff9092169190911b16151590565b34801561050c57600080fd5b506103b2604051806040016040528060058152602001640312e302e360dc1b81525081565b610539611eba565b6001600160a01b0381166105d957600080610552610f59565b6001600160a01b03164760405160006040518083038185875af1925050503d806000811461059c576040519150601f19603f3d011682016040523d82523d6000602084013e6105a1565b606091505b5091509150816105d257600047604051633a69abdb60e11b81526004016105c9929190613a14565b60405180910390fd5b5050610746565b803063db0463ba826105e9610f59565b6040516370a0823160e01b81526001600160a01b038616906370a08231906106159030906004016133f0565b602060405180830381865afa158015610632573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106569190613a2d565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156106a557600080fd5b505af19250505080156106b6575060015b610744576040516370a0823160e01b815282906001600160a01b038316906370a08231906106e89030906004016133f0565b602060405180830381865afa158015610705573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107299190613a2d565b604051633a69abdb60e11b81526004016105c9929190613a14565b505b610750600160c955565b50565b61075b611f1a565b6001600160a01b038116158061077a57506001600160a01b0381166001145b8061079d5750610788610f59565b6001600160a01b0316816001600160a01b0316145b806107b057506001600160a01b03811630145b156107d05780604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03818116600090815261012d6020526040902054161561080c5780604051632737ac7360e21b81526004016105c991906133f0565b6001600160a01b038216158061082b57506001600160a01b0382166001145b1561084b5781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03838116600090815261012d602052604090205481169083161461088b5781604051634f837c9960e01b81526004016105c991906133f0565b6001600160a01b03828116600081815261012d6020526040808220805486861680855283852080549288166001600160a01b03199384161790559589168452828420805482169096179095559290915281549092169055517f472cdd2f96ec512031842f7b11dd147ccbaa8767632d56b03038107f6fff9796906109109084906133f0565b60405180910390a17f7a475319b7eb5c5d3a6cc47a1db186497523ad8fcaf49406b6dfd0c8af58592c8160405161094791906133f0565b60405180910390a1505050565b6001600160a01b037f000000000000000000000000588e3a2b9a94d45a1a132ac948f2377fe48f262516300361099c5760405162461bcd60e51b81526004016105c990613a46565b7f000000000000000000000000588e3a2b9a94d45a1a132ac948f2377fe48f26256001600160a01b03166109ce611f79565b6001600160a01b0316146109f45760405162461bcd60e51b81526004016105c990613a92565b6109fd81611f95565b6040805160008082526020820190925261075091839190611f9d565b610a21611f1a565b610a29612108565b565b6001600160a01b037f000000000000000000000000588e3a2b9a94d45a1a132ac948f2377fe48f2625163003610a735760405162461bcd60e51b81526004016105c990613a46565b7f000000000000000000000000588e3a2b9a94d45a1a132ac948f2377fe48f26256001600160a01b0316610aa5611f79565b6001600160a01b031614610acb5760405162461bcd60e51b81526004016105c990613a92565b610ad482611f95565b610ae082826001611f9d565b5050565b6000306001600160a01b037f000000000000000000000000588e3a2b9a94d45a1a132ac948f2377fe48f26251614610b7f5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c6044820152771b1959081d1a1c9bdd59da0819195b1959d85d1958d85b1b60421b60648201526084016105c9565b50600080516020613d6e83398151915290565b61012e546060906000906001600160801b03166001600160401b03811115610bbc57610bbc6131d2565b604051908082528060200260200182016040528015610be5578160200160208202803683370190505b506001600090815261012d6020527fe278171178ecf2583e4e9c73c9a18d3ff0f6142f8f9926be1eba7c0b61591f5054919250906001600160a01b03165b6001600160a01b038116600114610c885780838381518110610c4757610c47613ade565b6001600160a01b03928316602091820292909201810191909152918116600090815261012d9092526040909120541681610c8081613b0a565b925050610c23565b509092915050565b60006001600160a01b038216600114801590610cc657506001600160a01b03828116600090815261012d60205260409020541615155b92915050565b610cd4611f1a565b6040516377aeb0ad60e01b815260040160405180910390fd5b610cf5611f1a565b610a29612154565b600080601960f81b600160f81b610d12612191565b604080517f8fba187ae9ab8a9763f7172f9bfd506ee0dfef805deabfbabbb76e3a3c44804d60208201529081018790526060015b60408051808303601f190181529082905280516020918201206001600160f81b0319958616918301919091529290931660218401526022830152604282015260620160408051601f1981840301815291905280516020909101209392505050565b600054610100900460ff1615808015610dc75750600054600160ff909116105b80610de15750303b158015610de1575060005460ff166001145b610e445760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016105c9565b6000805460ff191660011790558015610e67576000805461ff0019166101001790555b610e70856121e9565b610e7861223b565b610e8061226a565b610e88612299565b610e91306122c0565b6101305561013180546001600160a01b03191630179055610eb38484846123a3565b8383604051610ec3929190613b23565b6040518091039020856001600160a01b03167f85d93ec6e0feb0e3c2795fce5f86652db8f93cc41d48e40e409007cd365cea7984604051610f0491906131be565b60405180910390a38015610f52576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6097546001600160a01b031690565b610f70611f1a565b61012e546001600160801b0380831691161015610fb85761012e546040516313c3d1b160e01b81526001600160801b03808416600483015290911660248201526044016105c9565b6001600160a01b0382161580610fd757506001600160a01b0382166001145b15610ff75781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03838116600090815261012d60205260409020548116908316146110375781604051634f837c9960e01b81526004016105c991906133f0565b6001600160a01b03828116600081815261012d6020526040808220805488861684529183208054929095166001600160a01b031992831617909455918152825490911690915561012e80546001600160801b03169161109583613b65565b91906101000a8154816001600160801b0302191690836001600160801b03160217905550507f472cdd2f96ec512031842f7b11dd147ccbaa8767632d56b03038107f6fff9796826040516110e991906133f0565b60405180910390a161012e546001600160801b03828116600160801b90920416146111175761111781611365565b505050565b611124611f1a565b6001600160a01b038216158061114357506001600160a01b0382166001145b8061115657506001600160a01b03821630145b806111795750611164610f59565b6001600160a01b0316826001600160a01b0316145b156111995781604051634369193560e01b81526004016105c991906133f0565b6001600160a01b03828116600090815261012d602052604090205416156111d55781604051632737ac7360e21b81526004016105c991906133f0565b61012d6020527fe278171178ecf2583e4e9c73c9a18d3ff0f6142f8f9926be1eba7c0b61591f5080546001600160a01b038481166000818152604081208054939094166001600160a01b0319938416179093556001835283549091161790915561012e80546001600160801b03169161124d83613b88565b91906101000a8154816001600160801b0302191690836001600160801b03160217905550507f7a475319b7eb5c5d3a6cc47a1db186497523ad8fcaf49406b6dfd0c8af58592c826040516112a191906133f0565b60405180910390a161012e546001600160801b03828116600160801b9092041614610ae057610ae081611365565b60006112db83836125ce565b90506112e681610c90565b61130357604051635ce18fa560e01b815260040160405180910390fd5b66ffffffffffffff600884901c16600090815261012f602052604090208054600160ff86161b179055505050565b333014611351576040516325cdf54f60e21b815260040160405180910390fd5b6111176001600160a01b038416838361266f565b61136d611f1a565b61012e546001600160801b0390811690821611156113b65761012e546040516313c3d1b160e01b81526001600160801b03808416600483015290911660248201526044016105c9565b806001600160801b03166000036113e257806040516309f9112f60e01b81526004016105c991906131be565b61012e80546001600160801b03808416600160801b90810292821692909217928390556040517f610f7ff2b304ae8903c3de74c60c6ab1f7d6226b3f52c5161905bb5ad4039c9393611439939004909116906131be565b60405180910390a150565b600061144e610f59565b604080516001600160a01b039283166020820152828816918101919091529085166060820152608081018490526001600160401b03831660a082015260c0016040516020818303038152906040528051906020012090505b949350505050565b6114b6611eba565b6114be6126c5565b8651825160006001600160801b0383166001600160401b038111156114e5576114e56131d2565b60405190808252806020026020018201604052801561150e578160200160208202803683370190505b5090506001600160801b038316158061153157508851836001600160801b031614155b8061154657508751836001600160801b031614155b8061155b57508651836001600160801b031614155b1561157957604051630f36b20960e31b815260040160405180910390fd5b8351826001600160801b0316146115a35760405163706251a560e11b815260040160405180910390fd5b6115ad858561270b565b6000808a6000815181106115c3576115c3613ade565b6020026020010151905060005b856001600160801b03168110156119005761162d8a82815181106115f6576115f6613ade565b60200260200101516001600160401b0316600881901c600090815261012f6020526040902054600160ff9092169190911b16151590565b156116755789818151811061164457611644613ade565b602002602001015160405163e06a2eb760e01b81526004016105c991906001600160401b0391909116815260200190565b60006116f08e838151811061168c5761168c613ade565b60200260200101518e84815181106116a6576116a6613ade565b60200260200101518e85815181106116c0576116c0613ade565b60200260200101516001600160801b03168e86815181106116e3576116e3613ade565b6020026020010151611444565b90506000805b876001600160801b031681108015611720575061012e54600160801b90046001600160801b031682105b1561179e5761177b8c858151811061173a5761173a613ade565b6020026020010151828151811061175357611753613ade565b60200260200101518c838151811061176d5761176d613ade565b6020026020010151856127ea565b1561178c5761178982613b0a565b91505b8061179681613b0a565b9150506116f6565b5061012e54600160801b90046001600160801b031681106118eb5760018684815181106117cd576117cd613ade565b6020026020010190151590811515815250508d83815181106117f1576117f1613ade565b60200260200101516001600160a01b0316846001600160a01b0316146118ba578d838151811061182357611823613ade565b60200260200101516001600160a01b0316846001600160a01b0316111561188f57838e848151811061185757611857613ade565b6020026020010151604051632a60df1960e21b81526004016105c99291906001600160a01b0392831681529116602082015260400190565b6118998486612802565b8d83815181106118ab576118ab613ade565b60200260200101519350600094505b8c83815181106118cc576118cc613ade565b60200260200101516001600160801b0316856118e89190613bb6565b94505b505080806118f890613b0a565b9150506115d0565b508115611911576119118183612802565b505060005b836001600160801b0316811015611dd55781818151811061193957611939613ade565b6020026020010151801561195f575061195d8882815181106115f6576115f6613ade565b155b15611d335760006001600160a01b03168a828151811061198157611981613ade565b60200260200101516001600160a01b031603611b8a576000808c83815181106119ac576119ac613ade565b60200260200101516001600160a01b03168b84815181106119cf576119cf613ade565b60200260200101516001600160801b031660405160006040518083038185875af1925050503d8060008114611a20576040519150601f19603f3d011682016040523d82523d6000602084013e611a25565b606091505b509150915081611aab57600080516020613d4e83398151915260008e8581518110611a5257611a52613ade565b60200260200101518d8681518110611a6c57611a6c613ade565b60200260200101518d8781518110611a8657611a86613ade565b6020026020010151604051611a9e9493929190613bc9565b60405180910390a1611b83565b611af98a8481518110611ac057611ac0613ade565b60200260200101516001600160401b0316600881901c600090815261012f602052604090208054600160ff9093169290921b9091179055565b7fa0f991c2037f4be751314d611d7eb492af2256346379f5213899f5d7651d025560008e8581518110611b2e57611b2e613ade565b60200260200101518d8681518110611b4857611b48613ade565b60200260200101518d8781518110611b6257611b62613ade565b6020026020010151604051611b7a9493929190613bc9565b60405180910390a15b5050611dc3565b306001600160a01b031663db0463ba8b8381518110611bab57611bab613ade565b60200260200101518d8481518110611bc557611bc5613ade565b60200260200101518c8581518110611bdf57611bdf613ade565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526001600160801b03166044820152606401600060405180830381600087803b158015611c4257600080fd5b505af1925050508015611c53575060015b611ceb57600080516020613d4e8339815191528a8281518110611c7857611c78613ade565b60200260200101518c8381518110611c9257611c92613ade565b60200260200101518b8481518110611cac57611cac613ade565b60200260200101518b8581518110611cc657611cc6613ade565b6020026020010151604051611cde9493929190613bc9565b60405180910390a1611dc3565b611d00888281518110611ac057611ac0613ade565b7fa0f991c2037f4be751314d611d7eb492af2256346379f5213899f5d7651d02558a8281518110611c7857611c78613ade565b600080516020613d4e8339815191528a8281518110611d5457611d54613ade565b60200260200101518c8381518110611d6e57611d6e613ade565b60200260200101518b8481518110611d8857611d88613ade565b60200260200101518b8581518110611da257611da2613ade565b6020026020010151604051611dba9493929190613bc9565b60405180910390a15b80611dcd81613b0a565b915050611916565b50505050611de3600160c955565b50505050505050565b611df4611f1a565b6001600160a01b038116611e595760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105c9565b610750816121e9565b600080601960f81b600160f81b611e77612191565b604080517ff34b6449ec77bb4eafd875362be8394d87386afd5afa428225a2e7c45bfeea5760208201526001600160401b03881691810191909152606001610d46565b600260c95403611f0c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105c9565b600260c955565b600160c955565b33611f23610f59565b6001600160a01b031614610a295760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c9565b600080516020613d6e833981519152546001600160a01b031690565b610750611f1a565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611fd05761111783612932565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561202a575060408051601f3d908101601f1916820190925261202791810190613a2d565b60015b61208d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016105c9565b600080516020613d6e83398151915281146120fc5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016105c9565b506111178383836129ce565b6121106129f9565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161214a91906133f0565b60405180910390a1565b61215c6126c5565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861213d3390565b610131546000906001600160a01b0316301480156121ce57507f000000000000000000000000000000000000000000000000000000000000000146145b156121db57506101305490565b6121e4306122c0565b905090565b609780546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166122625760405162461bcd60e51b81526004016105c990613c03565b610a29612a42565b600054610100900460ff166122915760405162461bcd60e51b81526004016105c990613c03565b610a29612a75565b600054610100900460ff16610a295760405162461bcd60e51b81526004016105c990613c03565b604080518082018252600d81526c14185c98d95b14185e5c9bdb1b609a1b6020918201528151808301835260058152640312e302e360dc1b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818301527fed6e05651bd8011561b6b77e8887c7ee896d57d73bc8cb9896dd9cd314e7808d818401527f06c015bd22b4c69690933c1058878ebdfef31f9aaae40bbe86d8a09fe1b2972c60608201524660808201526001600160a01b039390931660a0808501919091528251808503909101815260c0909301909152815191012090565b61012e548290600160801b90046001600160801b0316156123d65760405162014d5560e71b815260040160405180910390fd5b80826001600160801b03161115612412576040516313c3d1b160e01b81526001600160801b0383166004820152602481018290526044016105c9565b6001826001600160801b0316101561243f57816040516309f9112f60e01b81526004016105c991906131be565b600160005b8281101561258857600086868381811061246057612460613ade565b90506020020160208101906124759190613156565b90506001600160a01b038116158061249657506001600160a01b0381166001145b806124a957506001600160a01b03811630145b806124cc57506124b7610f59565b6001600160a01b0316816001600160a01b0316145b156124ec5780604051634369193560e01b81526004016105c991906133f0565b806001600160a01b0316836001600160a01b0316148061252657506001600160a01b03818116600090815261012d60205260409020541615155b15612546578060405163f91658a960e01b81526004016105c991906133f0565b6001600160a01b03928316600090815261012d6020526040902080546001600160a01b031916938216939093179092558061258081613b0a565b915050612444565b506001600160a01b0316600090815261012d6020526040902080546001600160a01b03191660011790556001600160801b03918216600160801b0291161761012e555050565b6000806000806125dd85612a9c565b9194509250905060006125ef87611e62565b9050601e8460ff161115612658576040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052605c016040516020818303038152906040528051906020012090506004846126559190613c4e565b93505b61266481858585612adf565b979650505050505050565b6111178363a9059cbb60e01b848460405160240161268e929190613a14565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612b07565b60fb5460ff1615610a295760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016105c9565b81516000805b82811015610f5257600061275786838151811061273057612730613ade565b602002602001015186848151811061274a5761274a613ade565b6020026020010151612bd9565b90506001600160a01b0381166001148061278a57506001600160a01b03818116600090815261012d602052604090205416155b806127a75750826001600160a01b0316816001600160a01b031611155b156127e0578482815181106127be576127be613ade565b6020026020010151604051634ad00be960e11b81526004016105c9919061349b565b9150600101612711565b6000826127f78584612bfa565b1490505b9392505050565b60006001600160a01b03831615612887576040516370a0823160e01b81526001600160a01b038416906370a082319061283f9030906004016133f0565b602060405180830381865afa15801561285c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128809190613a2d565b905061288a565b50475b816001600160601b0316811061289f57505050565b73cfbfac74c26f8647cbdb8c5caf80bb5b32e43134634515641a6128c1610f59565b85306128cd8688613c67565b60008030604051806020016040528060008152506040518963ffffffff1660e01b8152600401612904989796959493929190613c8e565b600060405180830381600087803b15801561291e57600080fd5b505af1158015611de3573d6000803e3d6000fd5b6001600160a01b0381163b61299f5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016105c9565b600080516020613d6e83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b6129d783612c47565b6000825111806129e45750805b15611117576129f38383612c87565b50505050565b60fb5460ff16610a295760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016105c9565b600054610100900460ff16612a695760405162461bcd60e51b81526004016105c990613c03565b60fb805460ff19169055565b600054610100900460ff16611f135760405162461bcd60e51b81526004016105c990613c03565b60008060008351604114612ac357604051634be6321b60e01b815260040160405180910390fd5b5050506020810151604082015160609092015160001a92909190565b6000806000612af087878787612d7b565b91509150612afd81612e35565b5095945050505050565b6000612b5c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612f7a9092919063ffffffff16565b8051909150156111175780806020019051810190612b7a9190613cf9565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c9565b600080600080612be885612a9c565b9194509250905060006125ef87610cfd565b600081815b8451811015612c3f57612c2b82868381518110612c1e57612c1e613ade565b6020026020010151612f89565b915080612c3781613b0a565b915050612bff565b509392505050565b612c5081612932565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b612cef5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016105c9565b600080846001600160a01b031684604051612d0a9190613d1b565b600060405180830381855af49150503d8060008114612d45576040519150601f19603f3d011682016040523d82523d6000602084013e612d4a565b606091505b5091509150612d728282604051806060016040528060278152602001613d8e60279139612fb5565b95945050505050565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115612da85750600090506003612e2c565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612dfc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612e2557600060019250925050612e2c565b9150600090505b94509492505050565b6000816004811115612e4957612e49613d37565b03612e515750565b6001816004811115612e6557612e65613d37565b03612ead5760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b60448201526064016105c9565b6002816004811115612ec157612ec1613d37565b03612f0e5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016105c9565b6003816004811115612f2257612f22613d37565b036107505760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016105c9565b60606114a68484600085612fce565b6000818310612fa55760008281526020849052604090206127fb565b5060009182526020526040902090565b60608315612fc45750816127fb565b6127fb838361309e565b60608247101561302f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c9565b600080866001600160a01b0316858760405161304b9190613d1b565b60006040518083038185875af1925050503d8060008114613088576040519150601f19603f3d011682016040523d82523d6000602084013e61308d565b606091505b5091509150612664878383876130c8565b8151156130ae5781518083602001fd5b8060405162461bcd60e51b81526004016105c9919061349b565b60608315613137578251600003613130576001600160a01b0385163b6131305760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c9565b50816114a6565b6114a6838361309e565b6001600160a01b038116811461075057600080fd5b60006020828403121561316857600080fd5b81356127fb81613141565b60008060006060848603121561318857600080fd5b833561319381613141565b925060208401356131a381613141565b915060408401356131b381613141565b809150509250925092565b6001600160801b0391909116815260200190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613210576132106131d2565b604052919050565b600082601f83011261322957600080fd5b81356001600160401b03811115613242576132426131d2565b613255601f8201601f19166020016131e8565b81815284602083860101111561326a57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806040838503121561329a57600080fd5b82356132a581613141565b915060208301356001600160401b038111156132c057600080fd5b6132cc85828601613218565b9150509250929050565b6020808252825182820181905260009190848201906040850190845b818110156133175783516001600160a01b0316835292840192918401916001016132f2565b50909695505050505050565b60006020828403121561333557600080fd5b5035919050565b80356001600160801b038116811461335357600080fd5b919050565b6000806000806060858703121561336e57600080fd5b843561337981613141565b935060208501356001600160401b038082111561339557600080fd5b818701915087601f8301126133a957600080fd5b8135818111156133b857600080fd5b8860208260051b85010111156133cd57600080fd5b6020830195508094505050506133e56040860161333c565b905092959194509250565b6001600160a01b0391909116815260200190565b60008060006060848603121561341957600080fd5b833561342481613141565b9250602084013561343481613141565b91506134426040850161333c565b90509250925092565b60005b8381101561346657818101518382015260200161344e565b50506000910152565b6000815180845261348781602086016020860161344b565b601f01601f19169290920160200192915050565b6020815260006127fb602083018461346f565b600080604083850312156134c157600080fd5b82356134cc81613141565b91506134da6020840161333c565b90509250929050565b80356001600160401b038116811461335357600080fd5b6000806040838503121561350d57600080fd5b6132a5836134e3565b60008060006060848603121561352b57600080fd5b833561353681613141565b9250602084013561354681613141565b929592945050506040919091013590565b60006020828403121561356957600080fd5b6127fb8261333c565b6000806000806080858703121561358857600080fd5b843561359381613141565b935060208501356135a381613141565b9250604085013591506133e5606086016134e3565b60006001600160401b038211156135d1576135d16131d2565b5060051b60200190565b600082601f8301126135ec57600080fd5b813560206136016135fc836135b8565b6131e8565b82815260059290921b8401810191818101908684111561362057600080fd5b8286015b8481101561364457803561363781613141565b8352918301918301613624565b509695505050505050565b600082601f83011261366057600080fd5b813560206136706135fc836135b8565b82815260059290921b8401810191818101908684111561368f57600080fd5b8286015b84811015613644576136a48161333c565b8352918301918301613693565b600082601f8301126136c257600080fd5b813560206136d26135fc836135b8565b82815260059290921b840181019181810190868411156136f157600080fd5b8286015b8481101561364457613706816134e3565b83529183019183016136f5565b600082601f83011261372457600080fd5b813560206137346135fc836135b8565b82815260059290921b8401810191818101908684111561375357600080fd5b8286015b848110156136445780358352918301918301613757565b600082601f83011261377f57600080fd5b8135602061378f6135fc836135b8565b82815260059290921b840181019181810190868411156137ae57600080fd5b8286015b848110156136445780356001600160401b03808211156137d157600080fd5b818901915089603f8301126137e557600080fd5b858201356137f56135fc826135b8565b81815260059190911b830160400190878101908c83111561381557600080fd5b604085015b8381101561384e5780358581111561383157600080fd5b6138408f6040838a0101613713565b84525091890191890161381a565b508752505050928401925083016137b2565b600082601f83011261387157600080fd5b813560206138816135fc836135b8565b82815260059290921b840181019181810190868411156138a057600080fd5b8286015b848110156136445780356001600160401b038111156138c35760008081fd5b6138d18986838b0101613218565b8452509183019183016138a4565b600080600080600080600060e0888a0312156138fa57600080fd5b87356001600160401b038082111561391157600080fd5b61391d8b838c016135db565b985060208a013591508082111561393357600080fd5b61393f8b838c016135db565b975060408a013591508082111561395557600080fd5b6139618b838c0161364f565b965060608a013591508082111561397757600080fd5b6139838b838c016136b1565b955060808a013591508082111561399957600080fd5b6139a58b838c0161376e565b945060a08a01359150808211156139bb57600080fd5b6139c78b838c01613713565b935060c08a01359150808211156139dd57600080fd5b506139ea8a828b01613860565b91505092959891949750929550565b600060208284031215613a0b57600080fd5b6127fb826134e3565b6001600160a01b03929092168252602082015260400190565b600060208284031215613a3f57600080fd5b5051919050565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613b1c57613b1c613af4565b5060010190565b60008184825b85811015613b5a578135613b3c81613141565b6001600160a01b031683526020928301929190910190600101613b29565b509095945050505050565b60006001600160801b03821680613b7e57613b7e613af4565b6000190192915050565b60006001600160801b038281166002600160801b03198101613bac57613bac613af4565b6001019392505050565b80820180821115610cc657610cc6613af4565b6001600160a01b0394851681529290931660208301526001600160801b031660408201526001600160401b03909116606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60ff8281168282160390811115610cc657610cc6613af4565b6001600160601b03828116828216039080821115613c8757613c87613af4565b5092915050565b6001600160a01b038981168252888116602083015287811660408301526001600160601b0387811660608401528682166080840152851660a0830152831660c082015261010060e08201819052600090613cea8382018561346f565b9b9a5050505050505050505050565b600060208284031215613d0b57600080fd5b815180151581146127fb57600080fd5b60008251613d2d81846020870161344b565b9190910192915050565b634e487b7160e01b600052602160045260246000fdfe9466bd35fd7a18365ae41c835165ccc25ee9e2c96dccb8d232729fccfd678082360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220c15dc0def9dd4c1d4df8790dfebead2cf5f6ac61213d8ec38f837271861091a164736f6c63430008110033

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
[ Download: CSV Export  ]

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