APE Price: $1.15 (+13.22%)

Contract

0x1641D737e97916f1400CB6BA032eceE765484D9C

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo1.252354410437719732 APE

APE Value

$1.44 (@ $1.15/APE)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Set Default Read...42287642024-11-13 19:18:442 days ago1731525524IN
0x1641D737...765484D9C
0 APE0.0020145625.42069
Commit Verificat...42263322024-11-13 18:28:162 days ago1731522496IN
0x1641D737...765484D9C
0 APE0.0020820525.42069
Commit Verificat...42260112024-11-13 18:22:142 days ago1731522134IN
0x1641D737...765484D9C
0 APE0.0019297825.42069
Commit Verificat...42257292024-11-13 18:17:502 days ago1731521870IN
0x1641D737...765484D9C
0 APE0.0019297825.42069
Commit Verificat...41798272024-11-12 22:03:283 days ago1731449008IN
0x1641D737...765484D9C
0 APE0.0020826425.42069
Set Default Read...38859422024-11-08 22:33:017 days ago1731105181IN
0x1641D737...765484D9C
0 APE0.0027241525.42069
0x60e0604038781192024-11-08 19:57:197 days ago1731095839IN
 Create: ReadLib1002
0 APE0.1307818225.42069

Latest 9 internal transactions

Parent Transaction Hash Block From To
42263102024-11-13 18:27:562 days ago1731522476
0x1641D737...765484D9C
0.1380212 APE
42262512024-11-13 18:26:432 days ago1731522403
0x1641D737...765484D9C
0.1380212 APE
42260802024-11-13 18:23:252 days ago1731522205
0x1641D737...765484D9C
0.1380212 APE
42259912024-11-13 18:21:562 days ago1731522116
0x1641D737...765484D9C
0.1380212 APE
42257212024-11-13 18:17:412 days ago1731521861
0x1641D737...765484D9C
0.1380212 APE
42255562024-11-13 18:14:292 days ago1731521669
0x1641D737...765484D9C
0.1380212 APE
42253752024-11-13 18:11:312 days ago1731521491
0x1641D737...765484D9C
0.1380212 APE
42248872024-11-13 18:03:352 days ago1731521015
0x1641D737...765484D9C
0.1380212 APE
41798112024-11-12 22:03:043 days ago1731448984
0x1641D737...765484D9C
0.14818475 APE

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ReadLib1002

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
Yes with 20000 runs

Other Settings:
paris EvmVersion
File 1 of 32 : ReadLib1002.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { ERC165, IERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

import { ILayerZeroEndpointV2, MessagingFee, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { IMessageLib, MessageLibType, SetConfigParam } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLib.sol";
import { ISendLib, Packet } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ISendLib.sol";
import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";
import { Transfer } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/Transfer.sol";
import { AddressCast } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/AddressCast.sol";

import { ILayerZeroReadExecutor } from "../../interfaces/ILayerZeroReadExecutor.sol";
import { ILayerZeroReadDVN } from "../interfaces/ILayerZeroReadDVN.sol";
import { ILayerZeroTreasury } from "../../interfaces/ILayerZeroTreasury.sol";

import { UlnOptions } from "../libs/UlnOptions.sol";
import { DVNOptions } from "../libs/DVNOptions.sol";
import { SafeCall } from "../../libs/SafeCall.sol";

import { MessageLibBase } from "../../MessageLibBase.sol";
import { ReadLibBase, ReadLibConfig } from "./ReadLibBase.sol";

contract ReadLib1002 is ISendLib, ERC165, ReadLibBase, MessageLibBase {
    using PacketV1Codec for bytes;
    using SafeCall for address;

    uint32 internal constant CONFIG_TYPE_READ_LID_CONFIG = 1;

    uint16 internal constant TREASURY_MAX_COPY = 32;

    uint256 internal immutable treasuryGasLimit;

    mapping(address oapp => mapping(uint32 eid => mapping(uint64 nonce => bytes32 cmdHash))) public cmdHashLookup;
    mapping(bytes32 headerHash => mapping(bytes32 cmdHash => mapping(address dvn => bytes32 payloadHash)))
        public hashLookup;

    // accumulated fees for workers and treasury
    mapping(address worker => uint256 fee) public fees;
    uint256 internal treasuryNativeFeeCap;
    address internal treasury;

    event PayloadVerified(address dvn, bytes header, bytes32 cmdHash, bytes32 payloadHash);
    event ExecutorFeePaid(address executor, uint256 fee);
    event DVNFeePaid(address[] requiredDVNs, address[] optionalDVNs, uint256[] fees);
    event NativeFeeWithdrawn(address worker, address receiver, uint256 amount);
    event LzTokenFeeWithdrawn(address lzToken, address receiver, uint256 amount);
    event TreasurySet(address treasury);
    event TreasuryNativeFeeCapSet(uint256 newTreasuryNativeFeeCap);

    error LZ_RL_InvalidReceiver();
    error LZ_RL_InvalidPacketHeader();
    error LZ_RL_InvalidCmdHash();
    error LZ_RL_InvalidPacketVersion();
    error LZ_RL_InvalidEid();
    error LZ_RL_Verifying();
    error LZ_RL_InvalidConfigType(uint32 configType);
    error LZ_RL_InvalidAmount(uint256 requested, uint256 available);
    error LZ_RL_NotTreasury();
    error LZ_RL_CannotWithdrawAltToken();

    constructor(
        address _endpoint,
        uint256 _treasuryGasLimit,
        uint256 _treasuryGasForFeeCap
    ) MessageLibBase(_endpoint, ILayerZeroEndpointV2(_endpoint).eid()) {
        treasuryGasLimit = _treasuryGasLimit;
        treasuryNativeFeeCap = _treasuryGasForFeeCap;
    }

    function supportsInterface(bytes4 _interfaceId) public view override(ERC165, IERC165) returns (bool) {
        return
            _interfaceId == type(IMessageLib).interfaceId ||
            _interfaceId == type(ISendLib).interfaceId ||
            super.supportsInterface(_interfaceId);
    }

    // ============================ OnlyOwner ===================================

    function setTreasury(address _treasury) external onlyOwner {
        treasury = _treasury;
        emit TreasurySet(_treasury);
    }

    /// @dev the new value can not be greater than the old value, i.e. down only
    function setTreasuryNativeFeeCap(uint256 _newTreasuryNativeFeeCap) external onlyOwner {
        // assert the new value is no greater than the old value
        if (_newTreasuryNativeFeeCap > treasuryNativeFeeCap)
            revert LZ_RL_InvalidAmount(_newTreasuryNativeFeeCap, treasuryNativeFeeCap);
        treasuryNativeFeeCap = _newTreasuryNativeFeeCap;
        emit TreasuryNativeFeeCapSet(_newTreasuryNativeFeeCap);
    }

    // ============================ OnlyEndpoint ===================================

    function send(
        Packet calldata _packet,
        bytes calldata _options,
        bool _payInLzToken
    ) external onlyEndpoint returns (MessagingFee memory, bytes memory) {
        // the receiver must be the same as the sender
        if (AddressCast.toBytes32(_packet.sender) != _packet.receiver) revert LZ_RL_InvalidReceiver();

        // pay worker and treasury
        (bytes memory encodedPacket, uint256 totalNativeFee) = _payWorkers(_packet, _options);
        (uint256 treasuryNativeFee, uint256 lzTokenFee) = _payTreasury(
            _packet.sender,
            _packet.dstEid,
            totalNativeFee,
            _payInLzToken
        );
        totalNativeFee += treasuryNativeFee;

        // store the cmdHash for verification in order to prevent reorg attack
        cmdHashLookup[_packet.sender][_packet.dstEid][_packet.nonce] = keccak256(_packet.message);

        return (MessagingFee(totalNativeFee, lzTokenFee), encodedPacket);
    }

    function setConfig(address _oapp, SetConfigParam[] calldata _params) external onlyEndpoint {
        for (uint256 i = 0; i < _params.length; i++) {
            SetConfigParam calldata param = _params[i];
            _assertSupportedEid(param.eid);
            if (param.configType == CONFIG_TYPE_READ_LID_CONFIG) {
                _setReadLibConfig(param.eid, _oapp, abi.decode(param.config, (ReadLibConfig)));
            } else {
                revert LZ_RL_InvalidConfigType(param.configType);
            }
        }
    }

    // ============================ External ===================================
    /// @dev The verification will be done in the same chain where the packet is sent.
    /// @dev dont need to check endpoint verifiable here to save gas, as it will reverts if not verifiable.
    /// @param _packetHeader - the srcEid should be the localEid and the dstEid should be the channel id.
    ///        The original packet header in PacketSent event should be processed to flip the srcEid and dstEid.
    function commitVerification(bytes calldata _packetHeader, bytes32 _cmdHash, bytes32 _payloadHash) external {
        // assert packet header is of right size 81
        if (_packetHeader.length != 81) revert LZ_RL_InvalidPacketHeader();
        // assert packet header version is the same
        if (_packetHeader.version() != PacketV1Codec.PACKET_VERSION) revert LZ_RL_InvalidPacketVersion();
        // assert the packet is for this endpoint
        if (_packetHeader.dstEid() != localEid) revert LZ_RL_InvalidEid();

        // cache these values to save gas
        address receiver = _packetHeader.receiverB20();
        uint32 srcEid = _packetHeader.srcEid(); // channel id
        uint64 nonce = _packetHeader.nonce();

        // reorg protection. to allow reverification, the cmdHash cant be removed
        if (cmdHashLookup[receiver][srcEid][nonce] != _cmdHash) revert LZ_RL_InvalidCmdHash();

        ReadLibConfig memory config = getReadLibConfig(receiver, srcEid);
        _verifyAndReclaimStorage(config, keccak256(_packetHeader), _cmdHash, _payloadHash);

        // endpoint will revert if nonce <= lazyInboundNonce
        Origin memory origin = Origin(srcEid, _packetHeader.sender(), nonce);
        ILayerZeroEndpointV2(endpoint).verify(origin, receiver, _payloadHash);
    }

    /// @dev DVN verifies the payload with the packet header and command hash
    /// @param _packetHeader - the packet header is needed for event only, which can be conveniently for off-chain to track the packet state.
    function verify(bytes calldata _packetHeader, bytes32 _cmdHash, bytes32 _payloadHash) external {
        hashLookup[keccak256(_packetHeader)][_cmdHash][msg.sender] = _payloadHash;
        emit PayloadVerified(msg.sender, _packetHeader, _cmdHash, _payloadHash);
    }

    function withdrawFee(address _to, uint256 _amount) external {
        uint256 fee = fees[msg.sender];
        if (_amount > fee) revert LZ_RL_InvalidAmount(_amount, fee);
        unchecked {
            fees[msg.sender] = fee - _amount;
        }

        // transfers native if nativeToken == address(0x0)
        address nativeToken = ILayerZeroEndpointV2(endpoint).nativeToken();
        Transfer.nativeOrToken(nativeToken, _to, _amount);
        emit NativeFeeWithdrawn(msg.sender, _to, _amount);
    }

    // ============================ Treasury ===================================

    /// @dev _lzToken is a user-supplied value because lzToken might change in the endpoint before all lzToken can be taken out
    function withdrawLzTokenFee(address _lzToken, address _to, uint256 _amount) external {
        if (msg.sender != treasury) revert LZ_RL_NotTreasury();

        // lz token cannot be the same as the native token
        if (ILayerZeroEndpointV2(endpoint).nativeToken() == _lzToken) revert LZ_RL_CannotWithdrawAltToken();

        Transfer.token(_lzToken, _to, _amount);

        emit LzTokenFeeWithdrawn(_lzToken, _to, _amount);
    }

    // ============================ View ===================================

    function quote(
        Packet calldata _packet,
        bytes calldata _options,
        bool _payInLzToken
    ) external view returns (MessagingFee memory) {
        // split workers options
        (bytes memory executorOptions, bytes memory dvnOptions) = UlnOptions.decode(_options);

        address sender = _packet.sender;
        uint32 dstEid = _packet.dstEid;

        // quote the executor and dvns
        ReadLibConfig memory config = getReadLibConfig(sender, dstEid);
        uint256 nativeFee = _quoteDVNs(
            config,
            sender,
            PacketV1Codec.encodePacketHeader(_packet),
            _packet.message,
            dvnOptions
        );
        nativeFee += ILayerZeroReadExecutor(config.executor).getFee(sender, executorOptions);

        // quote treasury
        (uint256 treasuryNativeFee, uint256 lzTokenFee) = _quoteTreasury(sender, dstEid, nativeFee, _payInLzToken);
        nativeFee += treasuryNativeFee;

        return MessagingFee(nativeFee, lzTokenFee);
    }

    function verifiable(
        ReadLibConfig calldata _config,
        bytes32 _headerHash,
        bytes32 _cmdHash,
        bytes32 _payloadHash
    ) external view returns (bool) {
        return _checkVerifiable(_config, _headerHash, _cmdHash, _payloadHash);
    }

    function getConfig(uint32 _eid, address _oapp, uint32 _configType) external view returns (bytes memory) {
        if (_configType == CONFIG_TYPE_READ_LID_CONFIG) {
            return abi.encode(getReadLibConfig(_oapp, _eid));
        } else {
            revert LZ_RL_InvalidConfigType(_configType);
        }
    }

    function getTreasuryAndNativeFeeCap() external view returns (address, uint256) {
        return (treasury, treasuryNativeFeeCap);
    }

    function isSupportedEid(uint32 _eid) external view returns (bool) {
        return _isSupportedEid(_eid);
    }

    function messageLibType() external pure returns (MessageLibType) {
        return MessageLibType.SendAndReceive;
    }

    function version() external pure returns (uint64 major, uint8 minor, uint8 endpointVersion) {
        return (10, 0, 2);
    }

    // ============================ Internal ===================================

    /// 1/ handle executor
    /// 2/ handle other workers
    function _payWorkers(
        Packet calldata _packet,
        bytes calldata _options
    ) internal returns (bytes memory encodedPacket, uint256 totalNativeFee) {
        // split workers options
        (bytes memory executorOptions, bytes memory dvnOptions) = UlnOptions.decode(_options);

        // handle executor
        ReadLibConfig memory config = getReadLibConfig(_packet.sender, _packet.dstEid);
        totalNativeFee = _payExecutor(config.executor, _packet.sender, executorOptions);

        // handle dvns
        (uint256 dvnFee, bytes memory packetBytes) = _payDVNs(config, _packet, dvnOptions);
        totalNativeFee += dvnFee;

        encodedPacket = packetBytes;
    }

    function _payDVNs(
        ReadLibConfig memory _config,
        Packet calldata _packet,
        bytes memory _options
    ) internal returns (uint256 totalFee, bytes memory encodedPacket) {
        bytes memory packetHeader = PacketV1Codec.encodePacketHeader(_packet);
        bytes memory payload = PacketV1Codec.encodePayload(_packet);

        uint256[] memory dvnFees;
        (totalFee, dvnFees) = _assignDVNJobs(_config, _packet.sender, packetHeader, _packet.message, _options);

        encodedPacket = abi.encodePacked(packetHeader, payload);
        emit DVNFeePaid(_config.requiredDVNs, _config.optionalDVNs, dvnFees);
    }

    function _assignDVNJobs(
        ReadLibConfig memory _config,
        address _sender,
        bytes memory _packetHeader,
        bytes calldata _cmd,
        bytes memory _options
    ) internal returns (uint256 totalFee, uint256[] memory dvnFees) {
        (bytes[] memory optionsArray, uint8[] memory dvnIds) = DVNOptions.groupDVNOptionsByIdx(_options);

        uint8 dvnsLength = _config.requiredDVNCount + _config.optionalDVNCount;
        dvnFees = new uint256[](dvnsLength);
        for (uint8 i = 0; i < dvnsLength; ++i) {
            address dvn = i < _config.requiredDVNCount
                ? _config.requiredDVNs[i]
                : _config.optionalDVNs[i - _config.requiredDVNCount];

            bytes memory options = "";
            for (uint256 j = 0; j < dvnIds.length; ++j) {
                if (dvnIds[j] == i) {
                    options = optionsArray[j];
                    break;
                }
            }

            dvnFees[i] = ILayerZeroReadDVN(dvn).assignJob(_sender, _packetHeader, _cmd, options);
            if (dvnFees[i] > 0) {
                fees[dvn] += dvnFees[i];
                totalFee += dvnFees[i];
            }
        }
    }

    function _quoteDVNs(
        ReadLibConfig memory _config,
        address _sender,
        bytes memory _packetHeader,
        bytes calldata _cmd,
        bytes memory _options
    ) internal view returns (uint256 totalFee) {
        (bytes[] memory optionsArray, uint8[] memory dvnIndices) = DVNOptions.groupDVNOptionsByIdx(_options);

        // here we merge 2 list of dvns into 1 to allocate the indexed dvn options to the right dvn
        uint8 dvnsLength = _config.requiredDVNCount + _config.optionalDVNCount;
        for (uint8 i = 0; i < dvnsLength; ++i) {
            address dvn = i < _config.requiredDVNCount
                ? _config.requiredDVNs[i]
                : _config.optionalDVNs[i - _config.requiredDVNCount];

            bytes memory options = "";
            // it is a double loop here. however, if the list is short, the cost is very acceptable.
            for (uint256 j = 0; j < dvnIndices.length; ++j) {
                if (dvnIndices[j] == i) {
                    options = optionsArray[j];
                    break;
                }
            }
            totalFee += ILayerZeroReadDVN(dvn).getFee(_sender, _packetHeader, _cmd, options);
        }
    }

    function _payTreasury(
        address _sender,
        uint32 _dstEid,
        uint256 _totalNativeFee,
        bool _payInLzToken
    ) internal returns (uint256 treasuryNativeFee, uint256 lzTokenFee) {
        if (treasury != address(0x0)) {
            bytes memory callData = abi.encodeCall(
                ILayerZeroTreasury.payFee,
                (_sender, _dstEid, _totalNativeFee, _payInLzToken)
            );
            (bool success, bytes memory result) = treasury.safeCall(treasuryGasLimit, 0, TREASURY_MAX_COPY, callData);

            (treasuryNativeFee, lzTokenFee) = _parseTreasuryResult(_totalNativeFee, _payInLzToken, success, result);
            // fee should be in lzTokenFee if payInLzToken, otherwise in native
            if (treasuryNativeFee > 0) {
                fees[treasury] += treasuryNativeFee;
            }
        }
    }

    /// @dev this interface should be DoS-free if the user is paying with native. properties
    /// 1/ treasury can return an overly high lzToken fee
    /// 2/ if treasury returns an overly high native fee, it will be capped by maxNativeFee,
    ///    which can be reasoned with the configurations
    /// 3/ the owner can not configure the treasury in a way that force this function to revert
    function _quoteTreasury(
        address _sender,
        uint32 _dstEid,
        uint256 _totalNativeFee,
        bool _payInLzToken
    ) internal view returns (uint256 nativeFee, uint256 lzTokenFee) {
        // treasury must be set, and it has to be a contract
        if (treasury != address(0x0)) {
            bytes memory callData = abi.encodeCall(
                ILayerZeroTreasury.getFee,
                (_sender, _dstEid, _totalNativeFee, _payInLzToken)
            );
            (bool success, bytes memory result) = treasury.safeStaticCall(
                treasuryGasLimit,
                TREASURY_MAX_COPY,
                callData
            );

            return _parseTreasuryResult(_totalNativeFee, _payInLzToken, success, result);
        }
    }

    function _parseTreasuryResult(
        uint256 _totalNativeFee,
        bool _payInLzToken,
        bool _success,
        bytes memory _result
    ) internal view returns (uint256 nativeFee, uint256 lzTokenFee) {
        // failure, charges nothing
        if (!_success || _result.length < TREASURY_MAX_COPY) return (0, 0);

        // parse the result
        uint256 treasureFeeQuote = abi.decode(_result, (uint256));
        if (_payInLzToken) {
            lzTokenFee = treasureFeeQuote;
        } else {
            // pay in native
            // we must prevent high-treasuryFee Dos attack
            // nativeFee = min(treasureFeeQuote, maxNativeFee)
            // opportunistically raise the maxNativeFee to be the same as _totalNativeFee
            // can't use the _totalNativeFee alone because the oapp can use custom workers to force the fee to 0.
            // maxNativeFee = max (_totalNativeFee, treasuryNativeFeeCap)
            uint256 maxNativeFee = _totalNativeFee > treasuryNativeFeeCap ? _totalNativeFee : treasuryNativeFeeCap;

            // min (treasureFeeQuote, nativeFeeCap)
            nativeFee = treasureFeeQuote > maxNativeFee ? maxNativeFee : treasureFeeQuote;
        }
    }

    function _verifyAndReclaimStorage(
        ReadLibConfig memory _config,
        bytes32 _headerHash,
        bytes32 _cmdHash,
        bytes32 _payloadHash
    ) internal {
        if (!_checkVerifiable(_config, _headerHash, _cmdHash, _payloadHash)) {
            revert LZ_RL_Verifying();
        }

        // iterate the required DVNs
        if (_config.requiredDVNCount > 0) {
            for (uint8 i = 0; i < _config.requiredDVNCount; ++i) {
                delete hashLookup[_headerHash][_cmdHash][_config.requiredDVNs[i]];
            }
        }

        // iterate the optional DVNs
        if (_config.optionalDVNCount > 0) {
            for (uint8 i = 0; i < _config.optionalDVNCount; ++i) {
                delete hashLookup[_headerHash][_cmdHash][_config.optionalDVNs[i]];
            }
        }
    }

    /// @dev for verifiable view function
    /// @dev checks if this verification is ready to be committed to the endpoint
    function _checkVerifiable(
        ReadLibConfig memory _config,
        bytes32 _headerHash,
        bytes32 _cmdHash,
        bytes32 _payloadHash
    ) internal view returns (bool) {
        // iterate the required DVNs
        if (_config.requiredDVNCount > 0) {
            for (uint8 i = 0; i < _config.requiredDVNCount; ++i) {
                if (!_verified(_config.requiredDVNs[i], _headerHash, _cmdHash, _payloadHash)) {
                    // return if any of the required DVNs haven't signed
                    return false;
                }
            }
            if (_config.optionalDVNCount == 0) {
                // returns early if all required DVNs have signed and there are no optional DVNs
                return true;
            }
        }

        // then it must require optional validations
        uint8 threshold = _config.optionalDVNThreshold;
        for (uint8 i = 0; i < _config.optionalDVNCount; ++i) {
            if (_verified(_config.optionalDVNs[i], _headerHash, _cmdHash, _payloadHash)) {
                // increment the optional count if the optional DVN has signed
                threshold--;
                if (threshold == 0) {
                    // early return if the optional threshold has hit
                    return true;
                }
            }
        }

        // return false as a catch-all
        return false;
    }

    function _verified(
        address _dvn,
        bytes32 _headerHash,
        bytes32 _cmdHash,
        bytes32 _expectedPayloadHash
    ) internal view returns (bool verified) {
        verified = hashLookup[_headerHash][_cmdHash][_dvn] == _expectedPayloadHash;
    }

    function _payExecutor(
        address _executor,
        address _sender,
        bytes memory _executorOptions
    ) internal returns (uint256 executorFee) {
        executorFee = ILayerZeroReadExecutor(_executor).assignJob(_sender, _executorOptions);
        if (executorFee > 0) {
            fees[_executor] += executorFee;
        }
        emit ExecutorFeePaid(_executor, executorFee);
    }

    receive() external payable {}
}

File 2 of 32 : ILayerZeroEndpointV2.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import { IMessageLibManager } from "./IMessageLibManager.sol";
import { IMessagingComposer } from "./IMessagingComposer.sol";
import { IMessagingChannel } from "./IMessagingChannel.sol";
import { IMessagingContext } from "./IMessagingContext.sol";

struct MessagingParams {
    uint32 dstEid;
    bytes32 receiver;
    bytes message;
    bytes options;
    bool payInLzToken;
}

struct MessagingReceipt {
    bytes32 guid;
    uint64 nonce;
    MessagingFee fee;
}

struct MessagingFee {
    uint256 nativeFee;
    uint256 lzTokenFee;
}

struct Origin {
    uint32 srcEid;
    bytes32 sender;
    uint64 nonce;
}

interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
    event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);

    event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);

    event PacketDelivered(Origin origin, address receiver);

    event LzReceiveAlert(
        address indexed receiver,
        address indexed executor,
        Origin origin,
        bytes32 guid,
        uint256 gas,
        uint256 value,
        bytes message,
        bytes extraData,
        bytes reason
    );

    event LzTokenSet(address token);

    event DelegateSet(address sender, address delegate);

    function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);

    function send(
        MessagingParams calldata _params,
        address _refundAddress
    ) external payable returns (MessagingReceipt memory);

    function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;

    function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);

    function initializable(Origin calldata _origin, address _receiver) external view returns (bool);

    function lzReceive(
        Origin calldata _origin,
        address _receiver,
        bytes32 _guid,
        bytes calldata _message,
        bytes calldata _extraData
    ) external payable;

    // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
    function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;

    function setLzToken(address _lzToken) external;

    function lzToken() external view returns (address);

    function nativeToken() external view returns (address);

    function setDelegate(address _delegate) external;
}

File 3 of 32 : IMessageLib.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

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

import { SetConfigParam } from "./IMessageLibManager.sol";

enum MessageLibType {
    Send,
    Receive,
    SendAndReceive
}

interface IMessageLib is IERC165 {
    function setConfig(address _oapp, SetConfigParam[] calldata _config) external;

    function getConfig(uint32 _eid, address _oapp, uint32 _configType) external view returns (bytes memory config);

    function isSupportedEid(uint32 _eid) external view returns (bool);

    // message libs of same major version are compatible
    function version() external view returns (uint64 major, uint8 minor, uint8 endpointVersion);

    function messageLibType() external view returns (MessageLibType);
}

File 4 of 32 : IMessageLibManager.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

struct SetConfigParam {
    uint32 eid;
    uint32 configType;
    bytes config;
}

interface IMessageLibManager {
    struct Timeout {
        address lib;
        uint256 expiry;
    }

    event LibraryRegistered(address newLib);
    event DefaultSendLibrarySet(uint32 eid, address newLib);
    event DefaultReceiveLibrarySet(uint32 eid, address newLib);
    event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
    event SendLibrarySet(address sender, uint32 eid, address newLib);
    event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
    event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);

    function registerLibrary(address _lib) external;

    function isRegisteredLibrary(address _lib) external view returns (bool);

    function getRegisteredLibraries() external view returns (address[] memory);

    function setDefaultSendLibrary(uint32 _eid, address _newLib) external;

    function defaultSendLibrary(uint32 _eid) external view returns (address);

    function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;

    function defaultReceiveLibrary(uint32 _eid) external view returns (address);

    function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;

    function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);

    function isSupportedEid(uint32 _eid) external view returns (bool);

    function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);

    /// ------------------- OApp interfaces -------------------
    function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;

    function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);

    function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);

    function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;

    function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);

    function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;

    function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);

    function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;

    function getConfig(
        address _oapp,
        address _lib,
        uint32 _eid,
        uint32 _configType
    ) external view returns (bytes memory config);
}

File 5 of 32 : IMessagingChannel.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingChannel {
    event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
    event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
    event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);

    function eid() external view returns (uint32);

    // this is an emergency function if a message cannot be verified for some reasons
    // required to provide _nextNonce to avoid race condition
    function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;

    function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;

    function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;

    function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);

    function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);

    function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);

    function inboundPayloadHash(
        address _receiver,
        uint32 _srcEid,
        bytes32 _sender,
        uint64 _nonce
    ) external view returns (bytes32);

    function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
}

File 6 of 32 : IMessagingComposer.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingComposer {
    event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);
    event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);
    event LzComposeAlert(
        address indexed from,
        address indexed to,
        address indexed executor,
        bytes32 guid,
        uint16 index,
        uint256 gas,
        uint256 value,
        bytes message,
        bytes extraData,
        bytes reason
    );

    function composeQueue(
        address _from,
        address _to,
        bytes32 _guid,
        uint16 _index
    ) external view returns (bytes32 messageHash);

    function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;

    function lzCompose(
        address _from,
        address _to,
        bytes32 _guid,
        uint16 _index,
        bytes calldata _message,
        bytes calldata _extraData
    ) external payable;
}

File 7 of 32 : IMessagingContext.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface IMessagingContext {
    function isSendingMessage() external view returns (bool);

    function getSendContext() external view returns (uint32 dstEid, address sender);
}

File 8 of 32 : ISendLib.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import { MessagingFee } from "./ILayerZeroEndpointV2.sol";
import { IMessageLib } from "./IMessageLib.sol";

struct Packet {
    uint64 nonce;
    uint32 srcEid;
    address sender;
    uint32 dstEid;
    bytes32 receiver;
    bytes32 guid;
    bytes message;
}

interface ISendLib is IMessageLib {
    function send(
        Packet calldata _packet,
        bytes calldata _options,
        bool _payInLzToken
    ) external returns (MessagingFee memory, bytes memory encodedPacket);

    function quote(
        Packet calldata _packet,
        bytes calldata _options,
        bool _payInLzToken
    ) external view returns (MessagingFee memory);

    function setTreasury(address _treasury) external;

    function withdrawFee(address _to, uint256 _amount) external;

    function withdrawLzTokenFee(address _lzToken, address _to, uint256 _amount) external;
}

File 9 of 32 : AddressCast.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

library AddressCast {
    error AddressCast_InvalidSizeForAddress();
    error AddressCast_InvalidAddress();

    function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) {
        if (_addressBytes.length > 32) revert AddressCast_InvalidAddress();
        result = bytes32(_addressBytes);
        unchecked {
            uint256 offset = 32 - _addressBytes.length;
            result = result >> (offset * 8);
        }
    }

    function toBytes32(address _address) internal pure returns (bytes32 result) {
        result = bytes32(uint256(uint160(_address)));
    }

    function toBytes(bytes32 _addressBytes32, uint256 _size) internal pure returns (bytes memory result) {
        if (_size == 0 || _size > 32) revert AddressCast_InvalidSizeForAddress();
        result = new bytes(_size);
        unchecked {
            uint256 offset = 256 - _size * 8;
            assembly {
                mstore(add(result, 32), shl(offset, _addressBytes32))
            }
        }
    }

    function toAddress(bytes32 _addressBytes32) internal pure returns (address result) {
        result = address(uint160(uint256(_addressBytes32)));
    }

    function toAddress(bytes calldata _addressBytes) internal pure returns (address result) {
        if (_addressBytes.length != 20) revert AddressCast_InvalidAddress();
        result = address(bytes20(_addressBytes));
    }
}

File 10 of 32 : CalldataBytesLib.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

library CalldataBytesLib {
    function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) {
        return uint8(_bytes[_start]);
    }

    function toU16(bytes calldata _bytes, uint256 _start) internal pure returns (uint16) {
        unchecked {
            uint256 end = _start + 2;
            return uint16(bytes2(_bytes[_start:end]));
        }
    }

    function toU32(bytes calldata _bytes, uint256 _start) internal pure returns (uint32) {
        unchecked {
            uint256 end = _start + 4;
            return uint32(bytes4(_bytes[_start:end]));
        }
    }

    function toU64(bytes calldata _bytes, uint256 _start) internal pure returns (uint64) {
        unchecked {
            uint256 end = _start + 8;
            return uint64(bytes8(_bytes[_start:end]));
        }
    }

    function toU128(bytes calldata _bytes, uint256 _start) internal pure returns (uint128) {
        unchecked {
            uint256 end = _start + 16;
            return uint128(bytes16(_bytes[_start:end]));
        }
    }

    function toU256(bytes calldata _bytes, uint256 _start) internal pure returns (uint256) {
        unchecked {
            uint256 end = _start + 32;
            return uint256(bytes32(_bytes[_start:end]));
        }
    }

    function toAddr(bytes calldata _bytes, uint256 _start) internal pure returns (address) {
        unchecked {
            uint256 end = _start + 20;
            return address(bytes20(_bytes[_start:end]));
        }
    }

    function toB32(bytes calldata _bytes, uint256 _start) internal pure returns (bytes32) {
        unchecked {
            uint256 end = _start + 32;
            return bytes32(_bytes[_start:end]);
        }
    }
}

File 11 of 32 : Transfer.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

library Transfer {
    using SafeERC20 for IERC20;

    address internal constant ADDRESS_ZERO = address(0);

    error Transfer_NativeFailed(address _to, uint256 _value);
    error Transfer_ToAddressIsZero();

    function native(address _to, uint256 _value) internal {
        if (_to == ADDRESS_ZERO) revert Transfer_ToAddressIsZero();
        (bool success, ) = _to.call{ value: _value }("");
        if (!success) revert Transfer_NativeFailed(_to, _value);
    }

    function token(address _token, address _to, uint256 _value) internal {
        if (_to == ADDRESS_ZERO) revert Transfer_ToAddressIsZero();
        IERC20(_token).safeTransfer(_to, _value);
    }

    function nativeOrToken(address _token, address _to, uint256 _value) internal {
        if (_token == ADDRESS_ZERO) {
            native(_to, _value);
        } else {
            token(_token, _to, _value);
        }
    }
}

File 12 of 32 : BitMaps.sol
// SPDX-License-Identifier: MIT

// modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol
pragma solidity ^0.8.20;

type BitMap256 is uint256;

using BitMaps for BitMap256 global;

library BitMaps {
    /**
     * @dev Returns whether the bit at `index` is set.
     */
    function get(BitMap256 bitmap, uint8 index) internal pure returns (bool) {
        uint256 mask = 1 << index;
        return BitMap256.unwrap(bitmap) & mask != 0;
    }

    /**
     * @dev Sets the bit at `index`.
     */
    function set(BitMap256 bitmap, uint8 index) internal pure returns (BitMap256) {
        uint256 mask = 1 << index;
        return BitMap256.wrap(BitMap256.unwrap(bitmap) | mask);
    }
}

File 13 of 32 : ExecutorOptions.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { CalldataBytesLib } from "../../libs/CalldataBytesLib.sol";

library ExecutorOptions {
    using CalldataBytesLib for bytes;

    uint8 internal constant WORKER_ID = 1;

    uint8 internal constant OPTION_TYPE_LZRECEIVE = 1;
    uint8 internal constant OPTION_TYPE_NATIVE_DROP = 2;
    uint8 internal constant OPTION_TYPE_LZCOMPOSE = 3;
    uint8 internal constant OPTION_TYPE_ORDERED_EXECUTION = 4;

    error Executor_InvalidLzReceiveOption();
    error Executor_InvalidNativeDropOption();
    error Executor_InvalidLzComposeOption();

    /// @dev decode the next executor option from the options starting from the specified cursor
    /// @param _options [executor_id][executor_option][executor_id][executor_option]...
    ///        executor_option = [option_size][option_type][option]
    ///        option_size = len(option_type) + len(option)
    ///        executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes
    /// @param _cursor the cursor to start decoding from
    /// @return optionType the type of the option
    /// @return option the option of the executor
    /// @return cursor the cursor to start decoding the next executor option
    function nextExecutorOption(
        bytes calldata _options,
        uint256 _cursor
    ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
        unchecked {
            // skip worker id
            cursor = _cursor + 1;

            // read option size
            uint16 size = _options.toU16(cursor);
            cursor += 2;

            // read option type
            optionType = _options.toU8(cursor);

            // startCursor and endCursor are used to slice the option from _options
            uint256 startCursor = cursor + 1; // skip option type
            uint256 endCursor = cursor + size;
            option = _options[startCursor:endCursor];
            cursor += size;
        }
    }

    function decodeLzReceiveOption(bytes calldata _option) internal pure returns (uint128 gas, uint128 value) {
        if (_option.length != 16 && _option.length != 32) revert Executor_InvalidLzReceiveOption();
        gas = _option.toU128(0);
        value = _option.length == 32 ? _option.toU128(16) : 0;
    }

    function decodeNativeDropOption(bytes calldata _option) internal pure returns (uint128 amount, bytes32 receiver) {
        if (_option.length != 48) revert Executor_InvalidNativeDropOption();
        amount = _option.toU128(0);
        receiver = _option.toB32(16);
    }

    function decodeLzComposeOption(
        bytes calldata _option
    ) internal pure returns (uint16 index, uint128 gas, uint128 value) {
        if (_option.length != 18 && _option.length != 34) revert Executor_InvalidLzComposeOption();
        index = _option.toU16(0);
        gas = _option.toU128(2);
        value = _option.length == 34 ? _option.toU128(18) : 0;
    }

    function encodeLzReceiveOption(uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
        return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value);
    }

    function encodeNativeDropOption(uint128 _amount, bytes32 _receiver) internal pure returns (bytes memory) {
        return abi.encodePacked(_amount, _receiver);
    }

    function encodeLzComposeOption(uint16 _index, uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
        return _value == 0 ? abi.encodePacked(_index, _gas) : abi.encodePacked(_index, _gas, _value);
    }
}

File 14 of 32 : PacketV1Codec.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { Packet } from "../../interfaces/ISendLib.sol";
import { AddressCast } from "../../libs/AddressCast.sol";

library PacketV1Codec {
    using AddressCast for address;
    using AddressCast for bytes32;

    uint8 internal constant PACKET_VERSION = 1;

    // header (version + nonce + path)
    // version
    uint256 private constant PACKET_VERSION_OFFSET = 0;
    //    nonce
    uint256 private constant NONCE_OFFSET = 1;
    //    path
    uint256 private constant SRC_EID_OFFSET = 9;
    uint256 private constant SENDER_OFFSET = 13;
    uint256 private constant DST_EID_OFFSET = 45;
    uint256 private constant RECEIVER_OFFSET = 49;
    // payload (guid + message)
    uint256 private constant GUID_OFFSET = 81; // keccak256(nonce + path)
    uint256 private constant MESSAGE_OFFSET = 113;

    function encode(Packet memory _packet) internal pure returns (bytes memory encodedPacket) {
        encodedPacket = abi.encodePacked(
            PACKET_VERSION,
            _packet.nonce,
            _packet.srcEid,
            _packet.sender.toBytes32(),
            _packet.dstEid,
            _packet.receiver,
            _packet.guid,
            _packet.message
        );
    }

    function encodePacketHeader(Packet memory _packet) internal pure returns (bytes memory) {
        return
            abi.encodePacked(
                PACKET_VERSION,
                _packet.nonce,
                _packet.srcEid,
                _packet.sender.toBytes32(),
                _packet.dstEid,
                _packet.receiver
            );
    }

    function encodePayload(Packet memory _packet) internal pure returns (bytes memory) {
        return abi.encodePacked(_packet.guid, _packet.message);
    }

    function header(bytes calldata _packet) internal pure returns (bytes calldata) {
        return _packet[0:GUID_OFFSET];
    }

    function version(bytes calldata _packet) internal pure returns (uint8) {
        return uint8(bytes1(_packet[PACKET_VERSION_OFFSET:NONCE_OFFSET]));
    }

    function nonce(bytes calldata _packet) internal pure returns (uint64) {
        return uint64(bytes8(_packet[NONCE_OFFSET:SRC_EID_OFFSET]));
    }

    function srcEid(bytes calldata _packet) internal pure returns (uint32) {
        return uint32(bytes4(_packet[SRC_EID_OFFSET:SENDER_OFFSET]));
    }

    function sender(bytes calldata _packet) internal pure returns (bytes32) {
        return bytes32(_packet[SENDER_OFFSET:DST_EID_OFFSET]);
    }

    function senderAddressB20(bytes calldata _packet) internal pure returns (address) {
        return sender(_packet).toAddress();
    }

    function dstEid(bytes calldata _packet) internal pure returns (uint32) {
        return uint32(bytes4(_packet[DST_EID_OFFSET:RECEIVER_OFFSET]));
    }

    function receiver(bytes calldata _packet) internal pure returns (bytes32) {
        return bytes32(_packet[RECEIVER_OFFSET:GUID_OFFSET]);
    }

    function receiverB20(bytes calldata _packet) internal pure returns (address) {
        return receiver(_packet).toAddress();
    }

    function guid(bytes calldata _packet) internal pure returns (bytes32) {
        return bytes32(_packet[GUID_OFFSET:MESSAGE_OFFSET]);
    }

    function message(bytes calldata _packet) internal pure returns (bytes calldata) {
        return bytes(_packet[MESSAGE_OFFSET:]);
    }

    function payload(bytes calldata _packet) internal pure returns (bytes calldata) {
        return bytes(_packet[GUID_OFFSET:]);
    }

    function payloadHash(bytes calldata _packet) internal pure returns (bytes32) {
        return keccak256(payload(_packet));
    }
}

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

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

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

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

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

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

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

File 16 of 32 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 17 of 32 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    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 18 of 32 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

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

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

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

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

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

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 20 of 32 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 23 of 32 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.0;

/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {
    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.2._
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v2.5._
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.2._
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v2.5._
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v2.5._
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v2.5._
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v2.5._
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     *
     * _Available since v3.0._
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     *
     * _Available since v4.7._
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     *
     * _Available since v4.7._
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     *
     * _Available since v4.7._
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     *
     * _Available since v4.7._
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     *
     * _Available since v4.7._
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     *
     * _Available since v4.7._
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     *
     * _Available since v4.7._
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     *
     * _Available since v4.7._
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     *
     * _Available since v4.7._
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     *
     * _Available since v4.7._
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     *
     * _Available since v4.7._
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     *
     * _Available since v4.7._
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     *
     * _Available since v4.7._
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     *
     * _Available since v4.7._
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     *
     * _Available since v4.7._
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     *
     * _Available since v4.7._
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     *
     * _Available since v4.7._
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     *
     * _Available since v4.7._
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     *
     * _Available since v4.7._
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     *
     * _Available since v4.7._
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     *
     * _Available since v4.7._
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     *
     * _Available since v4.7._
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     *
     * _Available since v4.7._
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     *
     * _Available since v4.7._
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     *
     * _Available since v4.7._
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     *
     * _Available since v4.7._
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     *
     * _Available since v3.0._
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 24 of 32 : MessageLibBase.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

/// @dev simply a container of endpoint address and local eid
abstract contract MessageLibBase {
    address internal immutable endpoint;
    uint32 internal immutable localEid;

    error LZ_MessageLib_OnlyEndpoint();

    modifier onlyEndpoint() {
        if (endpoint != msg.sender) revert LZ_MessageLib_OnlyEndpoint();
        _;
    }

    constructor(address _endpoint, uint32 _localEid) {
        endpoint = _endpoint;
        localEid = _localEid;
    }
}

File 25 of 32 : ILayerZeroReadExecutor.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface ILayerZeroReadExecutor {
    // @notice query price and assign jobs at the same time
    // @param _sender - the source sending contract address. executors may apply price discrimination to senders
    // @param _options - optional parameters for extra service plugins, e.g. sending dust tokens at the destination chain
    function assignJob(address _sender, bytes calldata _options) external returns (uint256 fee);

    // @notice query the executor price for executing the payload on this chain
    // @param _sender - the source sending contract address. executors may apply price discrimination to senders
    // @param _options - optional parameters for extra service plugins, e.g. sending dust tokens
    function getFee(address _sender, bytes calldata _options) external view returns (uint256 fee);
}

File 26 of 32 : ILayerZeroTreasury.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface ILayerZeroTreasury {
    function getFee(
        address _sender,
        uint32 _dstEid,
        uint256 _totalNativeFee,
        bool _payInLzToken
    ) external view returns (uint256 fee);

    function payFee(
        address _sender,
        uint32 _dstEid,
        uint256 _totalNativeFee,
        bool _payInLzToken
    ) external payable returns (uint256 fee);
}

File 27 of 32 : SafeCall.sol
// SPDX-License-Identifier: MIT OR Apache-2.0

pragma solidity ^0.8.20;

/// @dev copied from https://github.com/nomad-xyz/ExcessivelySafeCall/blob/main/src/ExcessivelySafeCall.sol.
library SafeCall {
    /// @notice calls a contract with a specified gas limit and value and captures the return data
    /// @param _target The address to call
    /// @param _gas The amount of gas to forward to the remote contract
    /// @param _value The value in wei to send to the remote contract
    /// to memory.
    /// @param _maxCopy The maximum number of bytes of returndata to copy
    /// to memory.
    /// @param _calldata The data to send to the remote contract
    /// @return success and returndata, as `.call()`. Returndata is capped to
    /// `_maxCopy` bytes.
    function safeCall(
        address _target,
        uint256 _gas,
        uint256 _value,
        uint16 _maxCopy,
        bytes memory _calldata
    ) internal returns (bool, bytes memory) {
        // check that target has code
        uint size;
        assembly {
            size := extcodesize(_target)
        }
        if (size == 0) {
            return (false, new bytes(0));
        }

        // set up for assembly call
        uint256 _toCopy;
        bool _success;
        bytes memory _returnData = new bytes(_maxCopy);
        // dispatch message to recipient
        // by assembly calling "handle" function
        // we call via assembly to avoid memcopying a very large returndata
        // returned by a malicious contract
        assembly {
            _success := call(
                _gas, // gas
                _target, // recipient
                _value, // ether value
                add(_calldata, 0x20), // inloc
                mload(_calldata), // inlen
                0, // outloc
                0 // outlen
            )
            // limit our copy to 100 bytes
            _toCopy := returndatasize()
            if gt(_toCopy, _maxCopy) {
                _toCopy := _maxCopy
            }
            // Store the length of the copied bytes
            mstore(_returnData, _toCopy)
            // copy the bytes from returndata[0:_toCopy]
            returndatacopy(add(_returnData, 0x20), 0, _toCopy)
        }
        return (_success, _returnData);
    }

    /// @notice Use when you _really_ really _really_ don't trust the called
    /// contract. This prevents the called contract from causing reversion of
    /// the caller in as many ways as we can.
    /// @dev The main difference between this and a solidity low-level call is
    /// that we limit the number of bytes that the callee can cause to be
    /// copied to caller memory. This prevents stupid things like malicious
    /// contracts returning 10,000,000 bytes causing a local OOG when copying
    /// to memory.
    /// @param _target The address to call
    /// @param _gas The amount of gas to forward to the remote contract
    /// @param _maxCopy The maximum number of bytes of returndata to copy
    /// to memory.
    /// @param _calldata The data to send to the remote contract
    /// @return success and returndata, as `.call()`. Returndata is capped to
    /// `_maxCopy` bytes.
    function safeStaticCall(
        address _target,
        uint256 _gas,
        uint16 _maxCopy,
        bytes memory _calldata
    ) internal view returns (bool, bytes memory) {
        // check that target has code
        uint size;
        assembly {
            size := extcodesize(_target)
        }
        if (size == 0) {
            return (false, new bytes(0));
        }

        // set up for assembly call
        uint256 _toCopy;
        bool _success;
        bytes memory _returnData = new bytes(_maxCopy);
        // dispatch message to recipient
        // by assembly calling "handle" function
        // we call via assembly to avoid memcopying a very large returndata
        // returned by a malicious contract
        assembly {
            _success := staticcall(
                _gas, // gas
                _target, // recipient
                add(_calldata, 0x20), // inloc
                mload(_calldata), // inlen
                0, // outloc
                0 // outlen
            )
            // limit our copy to 256 bytes
            _toCopy := returndatasize()
            if gt(_toCopy, _maxCopy) {
                _toCopy := _maxCopy
            }
            // Store the length of the copied bytes
            mstore(_returnData, _toCopy)
            // copy the bytes from returndata[0:_toCopy]
            returndatacopy(add(_returnData, 0x20), 0, _toCopy)
        }
        return (_success, _returnData);
    }
}

File 28 of 32 : ILayerZeroReadDVN.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

interface ILayerZeroReadDVN {
    // @notice query price and assign jobs at the same time
    // @param _packetHeader - version + nonce + path
    // @param _cmd - the command to be executed to obtain the payload
    // @param _options - options
    function assignJob(
        address _sender,
        bytes calldata _packetHeader,
        bytes calldata _cmd,
        bytes calldata _options
    ) external payable returns (uint256 fee);

    // @notice query the dvn fee for relaying block information to the destination chain
    // @param _packetHeader - version + nonce + path
    // @param _cmd - the command to be executed to obtain the payload
    // @param _options - options
    function getFee(
        address _sender,
        bytes calldata _packetHeader,
        bytes calldata _cmd,
        bytes calldata _options
    ) external view returns (uint256 fee);
}

File 29 of 32 : DVNOptions.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol";

import { BitMap256 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol";
import { CalldataBytesLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol";

library DVNOptions {
    using CalldataBytesLib for bytes;
    using BytesLib for bytes;

    uint8 internal constant WORKER_ID = 2;
    uint8 internal constant OPTION_TYPE_PRECRIME = 1;

    error DVN_InvalidDVNIdx();
    error DVN_InvalidDVNOptions(uint256 cursor);

    /// @dev group dvn options by its idx
    /// @param _options [dvn_id][dvn_option][dvn_id][dvn_option]...
    ///        dvn_option = [option_size][dvn_idx][option_type][option]
    ///        option_size = len(dvn_idx) + len(option_type) + len(option)
    ///        dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes
    /// @return dvnOptions the grouped options, still share the same format of _options
    /// @return dvnIndices the dvn indices
    function groupDVNOptionsByIdx(
        bytes memory _options
    ) internal pure returns (bytes[] memory dvnOptions, uint8[] memory dvnIndices) {
        if (_options.length == 0) return (dvnOptions, dvnIndices);

        uint8 numDVNs = getNumDVNs(_options);

        // if there is only 1 dvn, we can just return the whole options
        if (numDVNs == 1) {
            dvnOptions = new bytes[](1);
            dvnOptions[0] = _options;

            dvnIndices = new uint8[](1);
            dvnIndices[0] = _options.toUint8(3); // dvn idx
            return (dvnOptions, dvnIndices);
        }

        // otherwise, we need to group the options by dvn_idx
        dvnIndices = new uint8[](numDVNs);
        dvnOptions = new bytes[](numDVNs);
        unchecked {
            uint256 cursor = 0;
            uint256 start = 0;
            uint8 lastDVNIdx = 255; // 255 is an invalid dvn_idx

            while (cursor < _options.length) {
                ++cursor; // skip worker_id

                // optionLength asserted in getNumDVNs (skip check)
                uint16 optionLength = _options.toUint16(cursor);
                cursor += 2;

                // dvnIdx asserted in getNumDVNs (skip check)
                uint8 dvnIdx = _options.toUint8(cursor);

                // dvnIdx must equal to the lastDVNIdx for the first option
                // so it is always skipped in the first option
                // this operation slices out options whenever the scan finds a different lastDVNIdx
                if (lastDVNIdx == 255) {
                    lastDVNIdx = dvnIdx;
                } else if (dvnIdx != lastDVNIdx) {
                    uint256 len = cursor - start - 3; // 3 is for worker_id and option_length
                    bytes memory opt = _options.slice(start, len);
                    _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, opt);

                    // reset the start and lastDVNIdx
                    start += len;
                    lastDVNIdx = dvnIdx;
                }

                cursor += optionLength;
            }

            // skip check the cursor here because the cursor is asserted in getNumDVNs
            // if we have reached the end of the options, we need to process the last dvn
            uint256 size = cursor - start;
            bytes memory op = _options.slice(start, size);
            _insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, op);

            // revert dvnIndices to start from 0
            for (uint8 i = 0; i < numDVNs; ++i) {
                --dvnIndices[i];
            }
        }
    }

    function _insertDVNOptions(
        bytes[] memory _dvnOptions,
        uint8[] memory _dvnIndices,
        uint8 _dvnIdx,
        bytes memory _newOptions
    ) internal pure {
        // dvnIdx starts from 0 but default value of dvnIndices is 0,
        // so we tell if the slot is empty by adding 1 to dvnIdx
        if (_dvnIdx == 255) revert DVN_InvalidDVNIdx();
        uint8 dvnIdxAdj = _dvnIdx + 1;

        for (uint256 j = 0; j < _dvnIndices.length; ++j) {
            uint8 index = _dvnIndices[j];
            if (dvnIdxAdj == index) {
                _dvnOptions[j] = abi.encodePacked(_dvnOptions[j], _newOptions);
                break;
            } else if (index == 0) {
                // empty slot, that means it is the first time we see this dvn
                _dvnIndices[j] = dvnIdxAdj;
                _dvnOptions[j] = _newOptions;
                break;
            }
        }
    }

    /// @dev get the number of unique dvns
    /// @param _options the format is the same as groupDVNOptionsByIdx
    function getNumDVNs(bytes memory _options) internal pure returns (uint8 numDVNs) {
        uint256 cursor = 0;
        BitMap256 bitmap;

        // find number of unique dvn_idx
        unchecked {
            while (cursor < _options.length) {
                ++cursor; // skip worker_id

                uint16 optionLength = _options.toUint16(cursor);
                cursor += 2;
                if (optionLength < 2) revert DVN_InvalidDVNOptions(cursor); // at least 1 byte for dvn_idx and 1 byte for option_type

                uint8 dvnIdx = _options.toUint8(cursor);

                // if dvnIdx is not set, increment numDVNs
                // max num of dvns is 255, 255 is an invalid dvn_idx
                // The order of the dvnIdx is not required to be sequential, as enforcing the order may weaken
                // the composability of the options. e.g. if we refrain from enforcing the order, an OApp that has
                // already enforced certain options can append additional options to the end of the enforced
                // ones without restrictions.
                if (dvnIdx == 255) revert DVN_InvalidDVNIdx();
                if (!bitmap.get(dvnIdx)) {
                    ++numDVNs;
                    bitmap = bitmap.set(dvnIdx);
                }

                cursor += optionLength;
            }
        }
        if (cursor != _options.length) revert DVN_InvalidDVNOptions(cursor);
    }

    /// @dev decode the next dvn option from _options starting from the specified cursor
    /// @param _options the format is the same as groupDVNOptionsByIdx
    /// @param _cursor the cursor to start decoding
    /// @return optionType the type of the option
    /// @return option the option
    /// @return cursor the cursor to start decoding the next option
    function nextDVNOption(
        bytes calldata _options,
        uint256 _cursor
    ) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
        unchecked {
            // skip worker id
            cursor = _cursor + 1;

            // read option size
            uint16 size = _options.toU16(cursor);
            cursor += 2;

            // read option type
            optionType = _options.toU8(cursor + 1); // skip dvn_idx

            // startCursor and endCursor are used to slice the option from _options
            uint256 startCursor = cursor + 2; // skip option type and dvn_idx
            uint256 endCursor = cursor + size;
            option = _options[startCursor:endCursor];
            cursor += size;
        }
    }
}

File 30 of 32 : UlnOptions.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";

import { ExecutorOptions } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol";

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

library UlnOptions {
    using SafeCast for uint256;

    uint16 internal constant TYPE_1 = 1; // legacy options type 1
    uint16 internal constant TYPE_2 = 2; // legacy options type 2
    uint16 internal constant TYPE_3 = 3;

    error LZ_ULN_InvalidWorkerOptions(uint256 cursor);
    error LZ_ULN_InvalidWorkerId(uint8 workerId);
    error LZ_ULN_InvalidLegacyType1Option();
    error LZ_ULN_InvalidLegacyType2Option();
    error LZ_ULN_UnsupportedOptionType(uint16 optionType);

    /// @dev decode the options into executorOptions and dvnOptions
    /// @param _options the options can be either legacy options (type 1 or 2) or type 3 options
    /// @return executorOptions the executor options, share the same format of type 3 options
    /// @return dvnOptions the dvn options, share the same format of type 3 options
    function decode(
        bytes calldata _options
    ) internal pure returns (bytes memory executorOptions, bytes memory dvnOptions) {
        // at least 2 bytes for the option type, but can have no options
        if (_options.length < 2) revert LZ_ULN_InvalidWorkerOptions(0);

        uint16 optionsType = uint16(bytes2(_options[0:2]));
        uint256 cursor = 2;

        // type3 options: [worker_option][worker_option]...
        // worker_option: [worker_id][option_size][option]
        // worker_id: uint8, option_size: uint16, option: bytes
        if (optionsType == TYPE_3) {
            unchecked {
                uint256 start = cursor;
                uint8 lastWorkerId; // worker_id starts from 1, so 0 is an invalid worker_id

                // heuristic: we assume that the options are mostly EXECUTOR options only
                // checking the workerID can reduce gas usage for most cases
                while (cursor < _options.length) {
                    uint8 workerId = uint8(bytes1(_options[cursor:cursor + 1]));
                    if (workerId == 0) revert LZ_ULN_InvalidWorkerId(0);

                    // workerId must equal to the lastWorkerId for the first option
                    // so it is always skipped in the first option
                    // this operation slices out options whenever the the scan finds a different workerId
                    if (lastWorkerId == 0) {
                        lastWorkerId = workerId;
                    } else if (workerId != lastWorkerId) {
                        bytes calldata op = _options[start:cursor]; // slice out the last worker's options
                        (executorOptions, dvnOptions) = _insertWorkerOptions(
                            executorOptions,
                            dvnOptions,
                            lastWorkerId,
                            op
                        );

                        // reset the start cursor and lastWorkerId
                        start = cursor;
                        lastWorkerId = workerId;
                    }

                    ++cursor; // for workerId

                    uint16 size = uint16(bytes2(_options[cursor:cursor + 2]));
                    if (size == 0) revert LZ_ULN_InvalidWorkerOptions(cursor);
                    cursor += size + 2;
                }

                // the options length must be the same as the cursor at the end
                if (cursor != _options.length) revert LZ_ULN_InvalidWorkerOptions(cursor);

                // if we have reached the end of the options and the options are not empty
                // we need to process the last worker's options
                if (_options.length > 2) {
                    bytes calldata op = _options[start:cursor];
                    (executorOptions, dvnOptions) = _insertWorkerOptions(executorOptions, dvnOptions, lastWorkerId, op);
                }
            }
        } else {
            executorOptions = decodeLegacyOptions(optionsType, _options);
        }
    }

    function _insertWorkerOptions(
        bytes memory _executorOptions,
        bytes memory _dvnOptions,
        uint8 _workerId,
        bytes calldata _newOptions
    ) private pure returns (bytes memory, bytes memory) {
        if (_workerId == ExecutorOptions.WORKER_ID) {
            _executorOptions = _executorOptions.length == 0
                ? _newOptions
                : abi.encodePacked(_executorOptions, _newOptions);
        } else if (_workerId == DVNOptions.WORKER_ID) {
            _dvnOptions = _dvnOptions.length == 0 ? _newOptions : abi.encodePacked(_dvnOptions, _newOptions);
        } else {
            revert LZ_ULN_InvalidWorkerId(_workerId);
        }
        return (_executorOptions, _dvnOptions);
    }

    /// @dev decode the legacy options (type 1 or 2) into executorOptions
    /// @param _optionType the legacy option type
    /// @param _options the legacy options, which still has the option type in the first 2 bytes
    /// @return executorOptions the executor options, share the same format of type 3 options
    /// Data format:
    /// legacy type 1: [extraGas]
    /// legacy type 2: [extraGas][dstNativeAmt][dstNativeAddress]
    /// extraGas: uint256, dstNativeAmt: uint256, dstNativeAddress: bytes
    function decodeLegacyOptions(
        uint16 _optionType,
        bytes calldata _options
    ) internal pure returns (bytes memory executorOptions) {
        if (_optionType == TYPE_1) {
            if (_options.length != 34) revert LZ_ULN_InvalidLegacyType1Option();

            // execution gas
            uint128 executionGas = uint256(bytes32(_options[2:2 + 32])).toUint128();

            // dont use the encode function in the ExecutorOptions lib for saving gas by calling abi.encodePacked once
            // the result is a lzReceive option: [executor_id][option_size][option_type][execution_gas]
            // option_type: uint8, execution_gas: uint128
            // option_size = len(option_type) + len(execution_gas) = 1 + 16 = 17
            executorOptions = abi.encodePacked(
                ExecutorOptions.WORKER_ID,
                uint16(17), // 16 + 1, 16 for option_length, + 1 for option_type
                ExecutorOptions.OPTION_TYPE_LZRECEIVE,
                executionGas
            );
        } else if (_optionType == TYPE_2) {
            // receiver size <= 32
            if (_options.length <= 66 || _options.length > 98) revert LZ_ULN_InvalidLegacyType2Option();

            // execution gas
            uint128 executionGas = uint256(bytes32(_options[2:2 + 32])).toUint128();

            // nativeDrop (amount + receiver)
            uint128 amount = uint256(bytes32(_options[34:34 + 32])).toUint128(); // offset 2 + 32
            bytes32 receiver;
            unchecked {
                uint256 receiverLen = _options.length - 66; // offset 2 + 32 + 32
                receiver = bytes32(_options[66:]);
                receiver = receiver >> (8 * (32 - receiverLen)); // padding 0 to the left
            }

            // dont use the encode function in the ExecutorOptions lib for saving gas by calling abi.encodePacked once
            // the result has one lzReceive option and one nativeDrop option:
            //      [executor_id][lzReceive_option_size][option_type][execution_gas] +
            //      [executor_id][nativeDrop_option_size][option_type][nativeDrop_amount][receiver]
            // option_type: uint8, execution_gas: uint128, nativeDrop_amount: uint128, receiver: bytes32
            // lzReceive_option_size = len(option_type) + len(execution_gas) = 1 + 16 = 17
            // nativeDrop_option_size = len(option_type) + len(nativeDrop_amount) + len(receiver) = 1 + 16 + 32 = 49
            executorOptions = abi.encodePacked(
                ExecutorOptions.WORKER_ID,
                uint16(17), // 16 + 1, 16 for option_length, + 1 for option_type
                ExecutorOptions.OPTION_TYPE_LZRECEIVE,
                executionGas,
                ExecutorOptions.WORKER_ID,
                uint16(49), // 48 + 1, 32 + 16 for option_length, + 1 for option_type
                ExecutorOptions.OPTION_TYPE_NATIVE_DROP,
                amount,
                receiver
            );
        } else {
            revert LZ_ULN_UnsupportedOptionType(_optionType);
        }
    }
}

File 31 of 32 : ReadLibBase.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";

struct ReadLibConfig {
    address executor;
    // we store the length of required DVNs and optional DVNs instead of using DVN.length directly to save gas
    uint8 requiredDVNCount; // 0 indicate DEFAULT, NIL_DVN_COUNT indicate NONE (to override the value of default)
    uint8 optionalDVNCount; // 0 indicate DEFAULT, NIL_DVN_COUNT indicate NONE (to override the value of default)
    uint8 optionalDVNThreshold; // (0, optionalDVNCount]
    address[] requiredDVNs; // no duplicates. sorted an an ascending order. allowed overlap with optionalDVNs
    address[] optionalDVNs; // no duplicates. sorted an an ascending order. allowed overlap with requiredDVNs
}

struct SetDefaultReadLibConfigParam {
    uint32 eid;
    ReadLibConfig config;
}

/// @dev includes the utility functions for checking ReadLib states and logics
abstract contract ReadLibBase is Ownable {
    address internal constant DEFAULT_CONFIG = address(0);
    // reserved values for
    uint8 internal constant DEFAULT = 0;
    uint8 internal constant NIL_DVN_COUNT = type(uint8).max;
    // 127 to prevent total number of DVNs (127 * 2) exceeding uint8.max (255)
    // by limiting the total size, it would help constraint the design of DVNOptions
    uint8 private constant MAX_COUNT = (type(uint8).max - 1) / 2;

    mapping(address oapp => mapping(uint32 eid => ReadLibConfig config)) internal readLibConfigs;

    error LZ_RL_Unsorted();
    error LZ_RL_InvalidRequiredDVNCount();
    error LZ_RL_InvalidOptionalDVNCount();
    error LZ_RL_AtLeastOneDVN();
    error LZ_RL_InvalidOptionalDVNThreshold();
    error LZ_RL_UnsupportedEid(uint32 eid);
    error LZ_RL_InvalidExecutor();

    event DefaultReadLibConfigsSet(SetDefaultReadLibConfigParam[] params);
    event ReadLibConfigSet(address oapp, uint32 eid, ReadLibConfig config);

    // ============================ OnlyOwner ===================================

    /// @dev about the DEFAULT ReadLib config
    /// 1) its values are all LITERAL (e.g. 0 is 0). whereas in the oapp ReadLib config, 0 (default value) points to the default ReadLib config
    ///     this design enables the oapp to point to DEFAULT config without explicitly setting the config
    /// 2) its configuration is more restrictive than the oapp ReadLib config that
    ///     a) it must not use NIL value, where NIL is used only by oapps to indicate the LITERAL 0
    ///     b) it must have at least one DVN and executor
    function setDefaultReadLibConfigs(SetDefaultReadLibConfigParam[] calldata _params) external onlyOwner {
        for (uint256 i = 0; i < _params.length; ++i) {
            SetDefaultReadLibConfigParam calldata param = _params[i];

            // 2.a must not use NIL
            if (param.config.requiredDVNCount == NIL_DVN_COUNT) revert LZ_RL_InvalidRequiredDVNCount();
            if (param.config.optionalDVNCount == NIL_DVN_COUNT) revert LZ_RL_InvalidOptionalDVNCount();

            // 2.b must have at least one dvn and executor
            _assertAtLeastOneDVN(param.config);
            if (param.config.executor == address(0x0)) revert LZ_RL_InvalidExecutor();

            _setConfig(DEFAULT_CONFIG, param.eid, param.config);
        }
        emit DefaultReadLibConfigsSet(_params);
    }

    // ============================ View ===================================
    // @dev assuming most oapps use default, we get default as memory and custom as storage to save gas
    function getReadLibConfig(address _oapp, uint32 _remoteEid) public view returns (ReadLibConfig memory rtnConfig) {
        ReadLibConfig storage defaultConfig = readLibConfigs[DEFAULT_CONFIG][_remoteEid];
        ReadLibConfig storage customConfig = readLibConfigs[_oapp][_remoteEid];

        address executor = customConfig.executor;
        rtnConfig.executor = executor != address(0x0) ? executor : defaultConfig.executor;

        if (customConfig.requiredDVNCount == DEFAULT) {
            if (defaultConfig.requiredDVNCount > 0) {
                // copy only if count > 0. save gas
                rtnConfig.requiredDVNs = defaultConfig.requiredDVNs;
                rtnConfig.requiredDVNCount = defaultConfig.requiredDVNCount;
            } // else, do nothing
        } else {
            if (customConfig.requiredDVNCount != NIL_DVN_COUNT) {
                rtnConfig.requiredDVNs = customConfig.requiredDVNs;
                rtnConfig.requiredDVNCount = customConfig.requiredDVNCount;
            } // else, do nothing
        }

        if (customConfig.optionalDVNCount == DEFAULT) {
            if (defaultConfig.optionalDVNCount > 0) {
                // copy only if count > 0. save gas
                rtnConfig.optionalDVNs = defaultConfig.optionalDVNs;
                rtnConfig.optionalDVNCount = defaultConfig.optionalDVNCount;
                rtnConfig.optionalDVNThreshold = defaultConfig.optionalDVNThreshold;
            }
        } else {
            if (customConfig.optionalDVNCount != NIL_DVN_COUNT) {
                rtnConfig.optionalDVNs = customConfig.optionalDVNs;
                rtnConfig.optionalDVNCount = customConfig.optionalDVNCount;
                rtnConfig.optionalDVNThreshold = customConfig.optionalDVNThreshold;
            }
        }

        // the final value must have at least one dvn
        // it is possible that some default config result into 0 dvns
        _assertAtLeastOneDVN(rtnConfig);
    }

    /// @dev Get the readLib config without the default config for the given remoteEid.
    function getAppReadLibConfig(address _oapp, uint32 _remoteEid) external view returns (ReadLibConfig memory) {
        return readLibConfigs[_oapp][_remoteEid];
    }

    // ============================ Internal ===================================
    function _setReadLibConfig(uint32 _remoteEid, address _oapp, ReadLibConfig memory _param) internal {
        _setConfig(_oapp, _remoteEid, _param);

        // get ReadLib config again as a catch all to ensure the config is valid
        getReadLibConfig(_oapp, _remoteEid);
        emit ReadLibConfigSet(_oapp, _remoteEid, _param);
    }

    /// @dev a supported Eid must have a valid default readLib config, which has at least one dvn
    function _isSupportedEid(uint32 _remoteEid) internal view returns (bool) {
        ReadLibConfig storage defaultConfig = readLibConfigs[DEFAULT_CONFIG][_remoteEid];
        return defaultConfig.requiredDVNCount > 0 || defaultConfig.optionalDVNThreshold > 0;
    }

    function _assertSupportedEid(uint32 _remoteEid) internal view {
        if (!_isSupportedEid(_remoteEid)) revert LZ_RL_UnsupportedEid(_remoteEid);
    }

    // ============================ Private ===================================

    function _assertAtLeastOneDVN(ReadLibConfig memory _config) private pure {
        if (_config.requiredDVNCount == 0 && _config.optionalDVNThreshold == 0) revert LZ_RL_AtLeastOneDVN();
    }

    /// @dev this private function is used in both setDefaultReadLibConfigs and setReadLibConfig
    function _setConfig(address _oapp, uint32 _eid, ReadLibConfig memory _param) private {
        // @dev required dvns
        // if dvnCount == NONE, dvns list must be empty
        // if dvnCount == DEFAULT, dvn list must be empty
        // otherwise, dvnList.length == dvnCount and assert the list is valid
        if (_param.requiredDVNCount == NIL_DVN_COUNT || _param.requiredDVNCount == DEFAULT) {
            if (_param.requiredDVNs.length != 0) revert LZ_RL_InvalidRequiredDVNCount();
        } else {
            if (_param.requiredDVNs.length != _param.requiredDVNCount || _param.requiredDVNCount > MAX_COUNT)
                revert LZ_RL_InvalidRequiredDVNCount();
            _assertNoDuplicates(_param.requiredDVNs);
        }

        // @dev optional dvns
        // if optionalDVNCount == NONE, optionalDVNs list must be empty and threshold must be 0
        // if optionalDVNCount == DEFAULT, optionalDVNs list must be empty and threshold must be 0
        // otherwise, optionalDVNs.length == optionalDVNCount, threshold > 0 && threshold <= optionalDVNCount and assert the list is valid

        // example use case: an oapp uses the DEFAULT 'required' but
        //     a) use a custom 1/1 dvn (practically a required dvn), or
        //     b) use a custom 2/3 dvn
        if (_param.optionalDVNCount == NIL_DVN_COUNT || _param.optionalDVNCount == DEFAULT) {
            if (_param.optionalDVNs.length != 0) revert LZ_RL_InvalidOptionalDVNCount();
            if (_param.optionalDVNThreshold != 0) revert LZ_RL_InvalidOptionalDVNThreshold();
        } else {
            if (_param.optionalDVNs.length != _param.optionalDVNCount || _param.optionalDVNCount > MAX_COUNT)
                revert LZ_RL_InvalidOptionalDVNCount();
            if (_param.optionalDVNThreshold == 0 || _param.optionalDVNThreshold > _param.optionalDVNCount)
                revert LZ_RL_InvalidOptionalDVNThreshold();
            _assertNoDuplicates(_param.optionalDVNs);
        }
        // don't assert valid count here, as it needs to be validated along side default config

        readLibConfigs[_oapp][_eid] = _param;
    }

    function _assertNoDuplicates(address[] memory _dvns) private pure {
        address lastDVN = address(0);
        for (uint256 i = 0; i < _dvns.length; i++) {
            address dvn = _dvns[i];
            if (dvn <= lastDVN) revert LZ_RL_Unsorted(); // to ensure no duplicates
            lastDVN = dvn;
        }
    }
}

File 32 of 32 : BytesLib.sol
// SPDX-License-Identifier: Unlicense
/*
 * @title Solidity Bytes Arrays Utils
 * @author Gonçalo Sá <[email protected]>
 *
 * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
 *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
 */
pragma solidity >=0.8.0 <0.9.0;


library BytesLib {
    function concat(
        bytes memory _preBytes,
        bytes memory _postBytes
    )
        internal
        pure
        returns (bytes memory)
    {
        bytes memory tempBytes;

        assembly {
            // Get a location of some free memory and store it in tempBytes as
            // Solidity does for memory variables.
            tempBytes := mload(0x40)

            // Store the length of the first bytes array at the beginning of
            // the memory for tempBytes.
            let length := mload(_preBytes)
            mstore(tempBytes, length)

            // Maintain a memory counter for the current write location in the
            // temp bytes array by adding the 32 bytes for the array length to
            // the starting location.
            let mc := add(tempBytes, 0x20)
            // Stop copying when the memory counter reaches the length of the
            // first bytes array.
            let end := add(mc, length)

            for {
                // Initialize a copy counter to the start of the _preBytes data,
                // 32 bytes into its memory.
                let cc := add(_preBytes, 0x20)
            } lt(mc, end) {
                // Increase both counters by 32 bytes each iteration.
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                // Write the _preBytes data into the tempBytes memory 32 bytes
                // at a time.
                mstore(mc, mload(cc))
            }

            // Add the length of _postBytes to the current length of tempBytes
            // and store it as the new length in the first 32 bytes of the
            // tempBytes memory.
            length := mload(_postBytes)
            mstore(tempBytes, add(length, mload(tempBytes)))

            // Move the memory counter back from a multiple of 0x20 to the
            // actual end of the _preBytes data.
            mc := end
            // Stop copying when the memory counter reaches the new combined
            // length of the arrays.
            end := add(mc, length)

            for {
                let cc := add(_postBytes, 0x20)
            } lt(mc, end) {
                mc := add(mc, 0x20)
                cc := add(cc, 0x20)
            } {
                mstore(mc, mload(cc))
            }

            // Update the free-memory pointer by padding our last write location
            // to 32 bytes: add 31 bytes to the end of tempBytes to move to the
            // next 32 byte block, then round down to the nearest multiple of
            // 32. If the sum of the length of the two arrays is zero then add
            // one before rounding down to leave a blank 32 bytes (the length block with 0).
            mstore(0x40, and(
              add(add(end, iszero(add(length, mload(_preBytes)))), 31),
              not(31) // Round down to the nearest 32 bytes.
            ))
        }

        return tempBytes;
    }

    function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
        assembly {
            // Read the first 32 bytes of _preBytes storage, which is the length
            // of the array. (We don't need to use the offset into the slot
            // because arrays use the entire slot.)
            let fslot := sload(_preBytes.slot)
            // Arrays of 31 bytes or less have an even value in their slot,
            // while longer arrays have an odd value. The actual length is
            // the slot divided by two for odd values, and the lowest order
            // byte divided by two for even values.
            // If the slot is even, bitwise and the slot with 255 and divide by
            // two to get the length. If the slot is odd, bitwise and the slot
            // with -1 and divide by two.
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)
            let newlength := add(slength, mlength)
            // slength can contain both the length and contents of the array
            // if length < 32 bytes so let's prepare for that
            // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
            switch add(lt(slength, 32), lt(newlength, 32))
            case 2 {
                // Since the new array still fits in the slot, we just need to
                // update the contents of the slot.
                // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
                sstore(
                    _preBytes.slot,
                    // all the modifications to the slot are inside this
                    // next block
                    add(
                        // we can just add to the slot contents because the
                        // bytes we want to change are the LSBs
                        fslot,
                        add(
                            mul(
                                div(
                                    // load the bytes from memory
                                    mload(add(_postBytes, 0x20)),
                                    // zero all bytes to the right
                                    exp(0x100, sub(32, mlength))
                                ),
                                // and now shift left the number of bytes to
                                // leave space for the length in the slot
                                exp(0x100, sub(32, newlength))
                            ),
                            // increase length by the double of the memory
                            // bytes length
                            mul(mlength, 2)
                        )
                    )
                )
            }
            case 1 {
                // The stored value fits in the slot, but the combined value
                // will exceed it.
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // The contents of the _postBytes array start 32 bytes into
                // the structure. Our first read should obtain the `submod`
                // bytes that can fit into the unused space in the last word
                // of the stored array. To get this, we read 32 bytes starting
                // from `submod`, so the data we read overlaps with the array
                // contents by `submod` bytes. Masking the lowest-order
                // `submod` bytes allows us to add that value directly to the
                // stored value.

                let submod := sub(32, slength)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(
                    sc,
                    add(
                        and(
                            fslot,
                            0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
                        ),
                        and(mload(mc), mask)
                    )
                )

                for {
                    mc := add(mc, 0x20)
                    sc := add(sc, 1)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
            default {
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                // Start copying to the last used word of the stored array.
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // Copy over the first `submod` bytes of the new data as in
                // case 1 above.
                let slengthmod := mod(slength, 32)
                let mlengthmod := mod(mlength, 32)
                let submod := sub(32, slengthmod)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(sc, add(sload(sc), and(mload(mc), mask)))

                for {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
        }
    }

    function slice(
        bytes memory _bytes,
        uint256 _start,
        uint256 _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_length + 31 >= _length, "slice_overflow");
        require(_bytes.length >= _start + _length, "slice_outOfBounds");

        bytes memory tempBytes;

        assembly {
            switch iszero(_length)
            case 0 {
                // Get a location of some free memory and store it in tempBytes as
                // Solidity does for memory variables.
                tempBytes := mload(0x40)

                // The first word of the slice result is potentially a partial
                // word read from the original array. To read it, we calculate
                // the length of that partial word and start copying that many
                // bytes into the array. The first word we copy will start with
                // data we don't care about, but the last `lengthmod` bytes will
                // land at the beginning of the contents of the new array. When
                // we're done copying, we overwrite the full first word with
                // the actual length of the slice.
                let lengthmod := and(_length, 31)

                // The multiplication in the next line is necessary
                // because when slicing multiples of 32 bytes (lengthmod == 0)
                // the following copy loop was copying the origin's length
                // and then ending prematurely not copying everything it should.
                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                let end := add(mc, _length)

                for {
                    // The multiplication in the next line has the same exact purpose
                    // as the one above.
                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                } lt(mc, end) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    mstore(mc, mload(cc))
                }

                mstore(tempBytes, _length)

                //update free-memory pointer
                //allocating the array padded to 32 bytes like the compiler does now
                mstore(0x40, and(add(mc, 31), not(31)))
            }
            //if we want a zero-length slice let's just return a zero-length array
            default {
                tempBytes := mload(0x40)
                //zero out the 32 bytes slice we are about to return
                //we need to do it because Solidity does not garbage collect
                mstore(tempBytes, 0)

                mstore(0x40, add(tempBytes, 0x20))
            }
        }

        return tempBytes;
    }

    function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
        require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
        address tempAddress;

        assembly {
            tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
        }

        return tempAddress;
    }

    function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
        require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
        uint8 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x1), _start))
        }

        return tempUint;
    }

    function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
        require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
        uint16 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x2), _start))
        }

        return tempUint;
    }

    function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
        require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
        uint32 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x4), _start))
        }

        return tempUint;
    }

    function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
        require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
        uint64 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x8), _start))
        }

        return tempUint;
    }

    function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
        require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
        uint96 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0xc), _start))
        }

        return tempUint;
    }

    function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
        require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
        uint128 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x10), _start))
        }

        return tempUint;
    }

    function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
        require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
        uint256 tempUint;

        assembly {
            tempUint := mload(add(add(_bytes, 0x20), _start))
        }

        return tempUint;
    }

    function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
        require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
        bytes32 tempBytes32;

        assembly {
            tempBytes32 := mload(add(add(_bytes, 0x20), _start))
        }

        return tempBytes32;
    }

    function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
        bool success = true;

        assembly {
            let length := mload(_preBytes)

            // if lengths don't match the arrays are not equal
            switch eq(length, mload(_postBytes))
            case 1 {
                // cb is a circuit breaker in the for loop since there's
                //  no said feature for inline assembly loops
                // cb = 1 - don't breaker
                // cb = 0 - break
                let cb := 1

                let mc := add(_preBytes, 0x20)
                let end := add(mc, length)

                for {
                    let cc := add(_postBytes, 0x20)
                // the next line is the loop condition:
                // while(uint256(mc < end) + cb == 2)
                } eq(add(lt(mc, end), cb), 2) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    // if any of these checks fails then arrays are not equal
                    if iszero(eq(mload(mc), mload(cc))) {
                        // unsuccess:
                        success := 0
                        cb := 0
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }

    function equalStorage(
        bytes storage _preBytes,
        bytes memory _postBytes
    )
        internal
        view
        returns (bool)
    {
        bool success = true;

        assembly {
            // we know _preBytes_offset is 0
            let fslot := sload(_preBytes.slot)
            // Decode the length of the stored array like in concatStorage().
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)

            // if lengths don't match the arrays are not equal
            switch eq(slength, mlength)
            case 1 {
                // slength can contain both the length and contents of the array
                // if length < 32 bytes so let's prepare for that
                // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                if iszero(iszero(slength)) {
                    switch lt(slength, 32)
                    case 1 {
                        // blank the last byte which is the length
                        fslot := mul(div(fslot, 0x100), 0x100)

                        if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                            // unsuccess:
                            success := 0
                        }
                    }
                    default {
                        // cb is a circuit breaker in the for loop since there's
                        //  no said feature for inline assembly loops
                        // cb = 1 - don't breaker
                        // cb = 0 - break
                        let cb := 1

                        // get the keccak hash to get the contents of the array
                        mstore(0x0, _preBytes.slot)
                        let sc := keccak256(0x0, 0x20)

                        let mc := add(_postBytes, 0x20)
                        let end := add(mc, mlength)

                        // the next line is the loop condition:
                        // while(uint256(mc < end) + cb == 2)
                        for {} eq(add(lt(mc, end), cb), 2) {
                            sc := add(sc, 1)
                            mc := add(mc, 0x20)
                        } {
                            if iszero(eq(sload(sc), mload(mc))) {
                                // unsuccess:
                                success := 0
                                cb := 0
                            }
                        }
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_endpoint","type":"address"},{"internalType":"uint256","name":"_treasuryGasLimit","type":"uint256"},{"internalType":"uint256","name":"_treasuryGasForFeeCap","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DVN_InvalidDVNIdx","type":"error"},{"inputs":[{"internalType":"uint256","name":"cursor","type":"uint256"}],"name":"DVN_InvalidDVNOptions","type":"error"},{"inputs":[],"name":"LZ_MessageLib_OnlyEndpoint","type":"error"},{"inputs":[],"name":"LZ_RL_AtLeastOneDVN","type":"error"},{"inputs":[],"name":"LZ_RL_CannotWithdrawAltToken","type":"error"},{"inputs":[{"internalType":"uint256","name":"requested","type":"uint256"},{"internalType":"uint256","name":"available","type":"uint256"}],"name":"LZ_RL_InvalidAmount","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidCmdHash","type":"error"},{"inputs":[{"internalType":"uint32","name":"configType","type":"uint32"}],"name":"LZ_RL_InvalidConfigType","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidEid","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidExecutor","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidOptionalDVNCount","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidOptionalDVNThreshold","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidPacketHeader","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidPacketVersion","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidReceiver","type":"error"},{"inputs":[],"name":"LZ_RL_InvalidRequiredDVNCount","type":"error"},{"inputs":[],"name":"LZ_RL_NotTreasury","type":"error"},{"inputs":[],"name":"LZ_RL_Unsorted","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"LZ_RL_UnsupportedEid","type":"error"},{"inputs":[],"name":"LZ_RL_Verifying","type":"error"},{"inputs":[],"name":"LZ_ULN_InvalidLegacyType1Option","type":"error"},{"inputs":[],"name":"LZ_ULN_InvalidLegacyType2Option","type":"error"},{"inputs":[{"internalType":"uint8","name":"workerId","type":"uint8"}],"name":"LZ_ULN_InvalidWorkerId","type":"error"},{"inputs":[{"internalType":"uint256","name":"cursor","type":"uint256"}],"name":"LZ_ULN_InvalidWorkerOptions","type":"error"},{"inputs":[{"internalType":"uint16","name":"optionType","type":"uint16"}],"name":"LZ_ULN_UnsupportedOptionType","type":"error"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"Transfer_NativeFailed","type":"error"},{"inputs":[],"name":"Transfer_ToAddressIsZero","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"optionalDVNs","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"fees","type":"uint256[]"}],"name":"DVNFeePaid","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"internalType":"struct ReadLibConfig","name":"config","type":"tuple"}],"indexed":false,"internalType":"struct SetDefaultReadLibConfigParam[]","name":"params","type":"tuple[]"}],"name":"DefaultReadLibConfigsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"executor","type":"address"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"ExecutorFeePaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lzToken","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LzTokenFeeWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"worker","type":"address"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NativeFeeWithdrawn","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":"dvn","type":"address"},{"indexed":false,"internalType":"bytes","name":"header","type":"bytes"},{"indexed":false,"internalType":"bytes32","name":"cmdHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"name":"PayloadVerified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oapp","type":"address"},{"indexed":false,"internalType":"uint32","name":"eid","type":"uint32"},{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"indexed":false,"internalType":"struct ReadLibConfig","name":"config","type":"tuple"}],"name":"ReadLibConfigSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newTreasuryNativeFeeCap","type":"uint256"}],"name":"TreasuryNativeFeeCapSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"treasury","type":"address"}],"name":"TreasurySet","type":"event"},{"inputs":[{"internalType":"address","name":"oapp","type":"address"},{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"cmdHashLookup","outputs":[{"internalType":"bytes32","name":"cmdHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_packetHeader","type":"bytes"},{"internalType":"bytes32","name":"_cmdHash","type":"bytes32"},{"internalType":"bytes32","name":"_payloadHash","type":"bytes32"}],"name":"commitVerification","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"worker","type":"address"}],"name":"fees","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_oapp","type":"address"},{"internalType":"uint32","name":"_remoteEid","type":"uint32"}],"name":"getAppReadLibConfig","outputs":[{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"internalType":"struct ReadLibConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"address","name":"_oapp","type":"address"},{"internalType":"uint32","name":"_configType","type":"uint32"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_oapp","type":"address"},{"internalType":"uint32","name":"_remoteEid","type":"uint32"}],"name":"getReadLibConfig","outputs":[{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"internalType":"struct ReadLibConfig","name":"rtnConfig","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTreasuryAndNativeFeeCap","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"headerHash","type":"bytes32"},{"internalType":"bytes32","name":"cmdHash","type":"bytes32"},{"internalType":"address","name":"dvn","type":"address"}],"name":"hashLookup","outputs":[{"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"}],"name":"isSupportedEid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messageLibType","outputs":[{"internalType":"enum MessageLibType","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Packet","name":"_packet","type":"tuple"},{"internalType":"bytes","name":"_options","type":"bytes"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"quote","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"receiver","type":"bytes32"},{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct Packet","name":"_packet","type":"tuple"},{"internalType":"bytes","name":"_options","type":"bytes"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"send","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oapp","type":"address"},{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint32","name":"configType","type":"uint32"},{"internalType":"bytes","name":"config","type":"bytes"}],"internalType":"struct SetConfigParam[]","name":"_params","type":"tuple[]"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"internalType":"struct ReadLibConfig","name":"config","type":"tuple"}],"internalType":"struct SetDefaultReadLibConfigParam[]","name":"_params","type":"tuple[]"}],"name":"setDefaultReadLibConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newTreasuryNativeFeeCap","type":"uint256"}],"name":"setTreasuryNativeFeeCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"_interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"executor","type":"address"},{"internalType":"uint8","name":"requiredDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNCount","type":"uint8"},{"internalType":"uint8","name":"optionalDVNThreshold","type":"uint8"},{"internalType":"address[]","name":"requiredDVNs","type":"address[]"},{"internalType":"address[]","name":"optionalDVNs","type":"address[]"}],"internalType":"struct ReadLibConfig","name":"_config","type":"tuple"},{"internalType":"bytes32","name":"_headerHash","type":"bytes32"},{"internalType":"bytes32","name":"_cmdHash","type":"bytes32"},{"internalType":"bytes32","name":"_payloadHash","type":"bytes32"}],"name":"verifiable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"_packetHeader","type":"bytes"},{"internalType":"bytes32","name":"_cmdHash","type":"bytes32"},{"internalType":"bytes32","name":"_payloadHash","type":"bytes32"}],"name":"verify","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint64","name":"major","type":"uint64"},{"internalType":"uint8","name":"minor","type":"uint8"},{"internalType":"uint8","name":"endpointVersion","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_lzToken","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawLzTokenFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e06040523480156200001157600080fd5b5060405162005d9238038062005d9283398101604081905262000034916200011c565b82836001600160a01b031663416ecebf6040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000074573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200009a919062000161565b620000a533620000cc565b6001600160a01b0390911660805263ffffffff1660a05260c0919091526005555062000190565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000606084860312156200013257600080fd5b83516001600160a01b03811681146200014a57600080fd5b602085015160409095015190969495509392505050565b6000602082840312156200017457600080fd5b815163ffffffff811681146200018957600080fd5b9392505050565b60805160a05160c051615baf620001e3600039600081816120af0152612eed01526000610c6b0152600081816107290152818161086e015281816109eb01528181610e5a0152611bca0152615baf6000f3fe60806040526004361061019a5760003560e01c80637620fd01116100e1578063d15b0d491161008a578063f0f4426011610064578063f0f442601461052c578063f2fde38b1461054c578063faaebd211461056c578063fd9be5221461059957600080fd5b8063d15b0d49146104bf578063d80e9bd9146104df578063ea69d69d1461050c57600080fd5b80639c33abf7116100bb5780639c33abf714610452578063ab750e751461047f578063c85f4b4e1461049f57600080fd5b80637620fd01146103935780638da5cb5b146103f05780638eb0bf301461042557600080fd5b80633c782a5211610143578063594924da1161011d578063594924da1461033e5780636750cd4c1461035e578063715018a61461037e57600080fd5b80633c782a52146102a55780634389e58f146102e357806354fd4d501461031157600080fd5b80631fb51225116101745780631fb5122514610217578063200175f71461026357806320efd7221461028557600080fd5b806301ffc9a7146101a6578063052368ca146101db5780631881d94d146101fb57600080fd5b366101a157005b600080fd5b3480156101b257600080fd5b506101c66101c136600461478b565b6105b9565b60405190151581526020015b60405180910390f35b3480156101e757600080fd5b506101c66101f63660046147cd565b61069e565b34801561020757600080fd5b5060026040516101d29190614826565b34801561022357600080fd5b506102556102323660046148c5565b600260209081526000938452604080852082529284528284209052825290205481565b6040519081526020016101d2565b34801561026f57600080fd5b5061028361027e36600461490a565b6106bf565b005b34801561029157600080fd5b506102836102a0366004614997565b61086c565b3480156102b157600080fd5b506102556102c03660046149ec565b600360209081526000938452604080852082529284528284209052825290205481565b3480156102ef57600080fd5b506103036102fe366004614a75565b6109d3565b6040516101d2929190614b67565b34801561031d57600080fd5b5060408051600a8152600060208201526002918101919091526060016101d2565b34801561034a57600080fd5b50610283610359366004614b8b565b610be9565b34801561036a57600080fd5b506101c6610379366004614bdc565b610ec3565b34801561038a57600080fd5b50610283610ece565b34801561039f57600080fd5b506103c460065460055473ffffffffffffffffffffffffffffffffffffffff90911691565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101d2565b3480156103fc57600080fd5b5060005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d2565b34801561043157600080fd5b50610445610440366004614bf7565b610ee2565b6040516101d29190614cfc565b34801561045e57600080fd5b5061047261046d366004614d0f565b61132f565b6040516101d29190614d4b565b34801561048b57600080fd5b5061028361049a366004614b8b565b6113cf565b3480156104ab57600080fd5b506102836104ba366004614d5e565b61145a565b3480156104cb57600080fd5b506102836104da366004614da0565b611644565b3480156104eb57600080fd5b506104ff6104fa366004614a75565b6116d2565b6040516101d29190614db9565b34801561051857600080fd5b50610445610527366004614bf7565b611844565b34801561053857600080fd5b50610283610547366004614dd0565b611a04565b34801561055857600080fd5b50610283610567366004614dd0565b611a7f565b34801561057857600080fd5b50610255610587366004614dd0565b60046020526000908152604090205481565b3480156105a557600080fd5b506102836105b4366004614ded565b611b36565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f97f0258400000000000000000000000000000000000000000000000000000000148061064c57507fffffffff0000000000000000000000000000000000000000000000000000000082167fb6e9ace300000000000000000000000000000000000000000000000000000000145b8061069857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006106b46106ac86615025565b858585611cab565b90505b949350505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610710576040517f96830d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e1758bd86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b69190615031565b73ffffffffffffffffffffffffffffffffffffffff1603610803576040517fb77f504400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61080e838383611e21565b6040805173ffffffffffffffffffffffffffffffffffffffff8086168252841660208201529081018290527fe081464b7278501267de69fa85b7b9560b0ae05d5fbfaab9b1986c70356e2efe906060015b60405180910390a1505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1633146108db576040517f467409c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156109cd57368383838181106108f9576108f961504e565b905060200281019061090b919061507d565b905061092261091d6020830183614bdc565b611e94565b60016109346040830160208401614bdc565b63ffffffff16036109745761096f61094f6020830183614bdc565b8661095d60408501856150bb565b81019061096a9190615120565b611edb565b6109c4565b6109846040820160208301614bdc565b6040517f0cb84e8200000000000000000000000000000000000000000000000000000000815263ffffffff90911660048201526024015b60405180910390fd5b506001016108de565b50505050565b604080518082019091526000808252602082015260607f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163314610a58576040517f467409c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6080860135610a89610a706060890160408a01614dd0565b73ffffffffffffffffffffffffffffffffffffffff1690565b14610ac0576040517fa4884a5900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610ace888888611f24565b9092509050600080610b00610ae960608c0160408d01614dd0565b610af960808d0160608e01614bdc565b858a611fad565b9092509050610b0f8284615184565b9250610b1e60c08b018b6150bb565b604051610b2c929190615197565b6040518091039020600260008c6040016020810190610b4b9190614dd0565b73ffffffffffffffffffffffffffffffffffffffff1681526020810191909152604001600090812090610b8460808e0160608f01614bdc565b63ffffffff168152602080820192909252604001600090812091610baa908e018e6151a7565b67ffffffffffffffff16815260208082019290925260409081016000209290925581518083019092529381529283015250925090505b94509492505050565b60518314610c23576040517f864d08b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001610c2f858561213b565b60ff1614610c69576040517f7952a82f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000063ffffffff16610c9a858561215d565b63ffffffff1614610cd7576040517f3e96df1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610ce38585612180565b90506000610cf18686612192565b90506000610cff87876121a2565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260026020908152604080832063ffffffff87168452825280832067ffffffffffffffff851684529091529020549091508514610d83576040517f660e96ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610d8f8484610ee2565b9050610db4818989604051610da5929190615197565b604051809103902088886121c5565b600060405180606001604052808563ffffffff168152602001610dd78b8b612362565b815267ffffffffffffffff858116602092830152604080517fa825d747000000000000000000000000000000000000000000000000000000008152845163ffffffff16600482015292840151602484015283015116604482015273ffffffffffffffffffffffffffffffffffffffff8781166064830152608482018990529192507f00000000000000000000000000000000000000000000000000000000000000009091169063a825d7479060a401600060405180830381600087803b158015610ea057600080fd5b505af1158015610eb4573d6000803e3d6000fd5b50505050505050505050505050565b60006106988261237b565b610ed66123fa565b610ee0600061247b565b565b6040805160c0810182526000808252602080830182905282840182905260608084018390526080840181905260a084015263ffffffff85168083527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49825284832073ffffffffffffffffffffffffffffffffffffffff888116855260018452868520928552919092529390912080549293919290911680610f9a57825473ffffffffffffffffffffffffffffffffffffffff16610f9c565b805b73ffffffffffffffffffffffffffffffffffffffff168452815474010000000000000000000000000000000000000000900460ff1661108e57825474010000000000000000000000000000000000000000900460ff1615611089578260010180548060200260200160405190810160405280929190818152602001828054801561105c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611031575b50505050506080850152825474010000000000000000000000000000000000000000900460ff1660208501525b611144565b815474010000000000000000000000000000000000000000900460ff90811614611144578160010180548060200260200160405190810160405280929190818152602001828054801561111757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116110ec575b50505050506080850152815474010000000000000000000000000000000000000000900460ff1660208501525b81547501000000000000000000000000000000000000000000900460ff166112435782547501000000000000000000000000000000000000000000900460ff161561123e57826002018054806020026020016040519081016040528092919081815260200182805480156111ee57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111c3575b505050505060a0850152825460ff75010000000000000000000000000000000000000000008204811660408701527601000000000000000000000000000000000000000000009091041660608501525b61131d565b81547501000000000000000000000000000000000000000000900460ff9081161461131d57816002018054806020026020016040519081016040528092919081815260200182805480156112cd57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116112a2575b505050505060a0850152815460ff75010000000000000000000000000000000000000000008204811660408701527601000000000000000000000000000000000000000000009091041660608501525b611326846124f0565b50505092915050565b60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff83160161138e576113688385610ee2565b6040516020016113789190614cfc565b60405160208183030381529060405290506113c8565b6040517f0cb84e8200000000000000000000000000000000000000000000000000000000815263ffffffff831660048201526024016109bb565b9392505050565b806003600086866040516113e4929190615197565b60408051918290039091208252602080830193909352908101600090812086825283528181203380835293528190209290925590517f04708e5dfef6005d6d646eb761e3b9e412e1cc5749fc9d884bca441cc7a952589161144c91879087908790879061520b565b60405180910390a150505050565b6114626123fa565b60005b8181101561160657368383838181106114805761148061504e565b9050602002810190611492919061524f565b905060ff6114a36020830183615283565b6114b49060408101906020016152b7565b60ff16036114ee576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60ff6114fd6020830183615283565b61150e9060608101906040016152b7565b60ff1603611548576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115666115586020830183615283565b61156190615025565b6124f0565b60006115756020830183615283565b611583906020810190614dd0565b73ffffffffffffffffffffffffffffffffffffffff16036115d0576040517f76df55a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115fd60006115e26020840184614bdc565b6115ef6020850185615283565b6115f890615025565b612541565b50600101611465565b507f65edb7dc0f21ba15c998f8bd220ea9fec30757ff9fb07696c634bcce00ce6f348282604051611638929190615384565b60405180910390a15050565b61164c6123fa565b600554811115611696576005546040517fb79d12630000000000000000000000000000000000000000000000000000000081526109bb918391600401918252602082015260400190565b60058190556040518181527f491ff913b5444f4136b0d4075f020cfe3a5f60de926ec0b091612401a22b7842906020015b60405180910390a150565b60408051808201909152600080825260208201526000806116f386866128f0565b9092509050600061170a6060890160408a01614dd0565b9050600061171e60808a0160608b01614bdc565b9050600061172c8383610ee2565b9050600061175c82856117466117418f6155bd565b612b31565b8e8060c0019061175691906150bb565b8a612c17565b82516040517fc8f8dcd100000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063c8f8dcd1906117b49087908a9060040161565b565b602060405180830381865afa1580156117d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f5919061568a565b6117ff9082615184565b90506000806118108686858d612deb565b909250905061181f8284615184565b6040805180820190915290815260208101919091529c9b505050505050505050505050565b6040805160c0810182526000808252602082018190529181018290526060808201929092526080810182905260a081019190915273ffffffffffffffffffffffffffffffffffffffff808416600090815260016020818152604080842063ffffffff88168552825292839020835160c0810185528154958616815260ff740100000000000000000000000000000000000000008704811682850152750100000000000000000000000000000000000000000087048116828701527601000000000000000000000000000000000000000000009096049095166060860152918201805484518184028101840190955280855292936080860193909283018282801561198457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611959575b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156119f357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116119c8575b505050505081525050905092915050565b611a0c6123fa565b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3c864541ef71378c6229510ed90f376565ee42d9c5e0904a984a9e863e6db44f906020016116c7565b611a876123fa565b73ffffffffffffffffffffffffffffffffffffffff8116611b2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109bb565b611b338161247b565b50565b3360009081526004602052604090205480821115611b8a576040517fb79d126300000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016109bb565b336000908152600460208181526040808420868603905580517fe1758bd800000000000000000000000000000000000000000000000000000000815290517f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169363e1758bd89383820193909291908290030181865afa158015611c27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4b9190615031565b9050611c58818585612f2f565b6040805133815273ffffffffffffffffffffffffffffffffffffffff861660208201529081018490527f820b7fd51bf79c54350bab98400651b3314ff6e79b33528821871d94a66698839060600161144c565b602084015160009060ff1615611d645760005b856020015160ff168160ff161015611d4c57611d3686608001518260ff1681518110611cec57611cec61504e565b6020026020010151868686600092835260036020908152604080852093855292815282842073ffffffffffffffffffffffffffffffffffffffff9095168452939093529020541490565b611d445760009150506106b7565b600101611cbe565b50846040015160ff16600003611d64575060016106b7565b606085015160005b866040015160ff168160ff161015611e1457611de48760a001518260ff1681518110611d9a57611d9a61504e565b6020026020010151878787600092835260036020908152604080852093855292815282842073ffffffffffffffffffffffffffffffffffffffff9095168452939093529020541490565b15611e0c5781611df3816156a3565b9250508160ff16600003611e0c576001925050506106b7565b600101611d6c565b5060009695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8216611e6e576040517f6b7a931000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e8f73ffffffffffffffffffffffffffffffffffffffff84168383612f5f565b505050565b611e9d8161237b565b611b33576040517f0ff03e5400000000000000000000000000000000000000000000000000000000815263ffffffff821660048201526024016109bb565b611ee6828483612541565b611ef08284610ee2565b507fe8e2a5b92fc69ac50188ea142042492be8e8c34febb10b2cd02983684336e14282848360405161085f939291906156de565b60606000806000611f3586866128f0565b90925090506000611f5f611f4f60608a0160408b01614dd0565b61044060808b0160608c01614bdc565b8051909150611f7e90611f7860608b0160408c01614dd0565b85612fec565b9350600080611f8e838b8661311f565b9092509050611f9d8287615184565b909a909950975050505050505050565b600654600090819073ffffffffffffffffffffffffffffffffffffffff1615610be05760405173ffffffffffffffffffffffffffffffffffffffff8716602482015263ffffffff8616604482015260648101859052831515608482015260009060a401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052602080820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd51c54860000000000000000000000000000000000000000000000000000000017905260065491925060009182916120d79173ffffffffffffffffffffffffffffffffffffffff16907f0000000000000000000000000000000000000000000000000000000000000000908490876131e7565b915091506120e787878484613298565b9095509350841561212f5760065473ffffffffffffffffffffffffffffffffffffffff1660009081526004602052604081208054879290612129908490615184565b90915550505b50505094509492505050565b600061214a6001828486615719565b61215391615743565b60f81c9392505050565b600061216d6031602d8486615719565b6121769161578b565b60e01c9392505050565b60006113c861218f8484613313565b90565b600061216d600d60098486615719565b60006121b2600960018486615719565b6121bb916157d1565b60c01c9392505050565b6121d184848484611cab565b612207576040517f28ca4b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084015160ff16156122b25760005b846020015160ff168160ff1610156122b057600084815260036020908152604080832086845290915281206080870151805191929160ff851690811061225f5761225f61504e565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055806001019050612217565b505b604084015160ff16156109cd5760005b846040015160ff168160ff16101561235b576000848152600360209081526040808320868452909152812060a0870151805191929160ff851690811061230a5761230a61504e565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090558060010190506122c2565b5050505050565b6000612372602d600d8486615719565b6113c891615817565b63ffffffff811660009081527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4960205260408120805474010000000000000000000000000000000000000000900460ff161515806113c8575054760100000000000000000000000000000000000000000000900460ff16151592915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ee0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109bb565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b602081015160ff1615801561250a5750606081015160ff16155b15611b33576040517f9b5f9f7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602081015160ff908116148061255c5750602081015160ff16155b156125a3576080810151511561259e576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612622565b806020015160ff168160800151511415806125de575060026125c7600160ff615853565b6125d1919061586c565b60ff16816020015160ff16115b15612615576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6126228160800151613323565b604081015160ff908116148061263d5750604081015160ff16155b156126c35760a0810151511561267f576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081015160ff16156126be576040517ff92940be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61279a565b806040015160ff168160a00151511415806126fe575060026126e7600160ff615853565b6126f1919061586c565b60ff16816040015160ff16115b15612735576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081015160ff1615806127565750806040015160ff16816060015160ff16115b1561278d576040517ff92940be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61279a8160a00151613323565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260016020818152604080842063ffffffff881685528252928390208551815487840151958801516060890151929097167fffffffffffffffffffffff000000000000000000000000000000000000000000909116177401000000000000000000000000000000000000000060ff96871602177fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000968616969096027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff169590951776010000000000000000000000000000000000000000000094909516939093029390931782556080840151805185946128cc9385019201906146f5565b5060a082015180516128e89160028401916020909101906146f5565b505050505050565b6060806002831015612931576040517f6592671c000000000000000000000000000000000000000000000000000000008152600060048201526024016109bb565b60006129406002828688615719565b612949916158b5565b60f01c905060027ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8201612b1a578060005b86831015612aa657600061299460018501858a8c615719565b61299d91615743565b60f81c905060008190036129e0576040517f6780cfaf000000000000000000000000000000000000000000000000000000008152600060048201526024016109bb565b8160ff166000036129f357809150612a30565b8160ff168160ff1614612a3057366000612a0f86868c8e615719565b91509150612a2089898685856133bd565b9099509750859450919250829150505b6001840193600090612a4790600301868b8d615719565b612a50916158b5565b60f01c90506000819003612a93576040517f6592671c000000000000000000000000000000000000000000000000000000008152600481018690526024016109bb565b8060020161ffff1685019450505061297b565b828714612ae2576040517f6592671c000000000000000000000000000000000000000000000000000000008152600481018490526024016109bb565b6002871115612b1357366000612afa85858b8d615719565b91509150612b0b88888585856133bd565b909850965050505b5050612b28565b612b25828787613532565b93505b50509250929050565b8051602080830151604080850151606080870151608088015193517f01000000000000000000000000000000000000000000000000000000000000009681019690965260c09690961b7fffffffffffffffff00000000000000000000000000000000000000000000000016602186015260e093841b7fffffffff00000000000000000000000000000000000000000000000000000000908116602987015273ffffffffffffffffffffffffffffffffffffffff909216602d8601529490921b909116604d83015260518201526071015b6040516020818303038152906040529050919050565b6000806000612c25846137b1565b91509150600089604001518a60200151612c3f91906158fb565b905060005b8160ff168160ff161015612ddd5760008b6020015160ff168260ff1610612c995760a08c015160208d0151612c799084615853565b60ff1681518110612c8c57612c8c61504e565b6020026020010151612cbb565b8b608001518260ff1681518110612cb257612cb261504e565b60200260200101515b60408051602081019091526000808252919250905b8551811015612d28578360ff16868281518110612cef57612cef61504e565b602002602001015160ff1603612d2057868181518110612d1157612d1161504e565b60200260200101519150612d28565b600101612cd0565b506040517ffdb9b0f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063fdb9b0f190612d83908f908f908f908f908890600401615914565b602060405180830381865afa158015612da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc4919061568a565b612dce9088615184565b96505050806001019050612c44565b505050509695505050505050565b600654600090819073ffffffffffffffffffffffffffffffffffffffff1615610be05760405173ffffffffffffffffffffffffffffffffffffffff8716602482015263ffffffff8616604482015260648101859052831515608482015260009060a401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052602080820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd4244221000000000000000000000000000000000000000000000000000000001790526006549192506000918291612f139173ffffffffffffffffffffffffffffffffffffffff16907f00000000000000000000000000000000000000000000000000000000000000009086613a55565b91509150612f2387878484613298565b94509450505050610be0565b73ffffffffffffffffffffffffffffffffffffffff8316612f5457611e8f8282613b02565b611e8f838383611e21565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611e8f908490613c08565b6040517fc015bb7d00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff85169063c015bb7d90613043908690869060040161565b565b6020604051808303816000875af1158015613062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613086919061568a565b905080156130c95773ffffffffffffffffffffffffffffffffffffffff8416600090815260046020526040812080548392906130c3908490615184565b90915550505b6040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018390527f61ed099e74a97a1d7f8bb0952a88ca8b7b8ebd00c126ea04671f92a81213318a910160405180910390a19392505050565b6000606081613130611741866155bd565b90506000613145613140876155bd565b613d17565b905060606131708861315c89840160408b01614dd0565b8561316a60c08c018c6150bb565b8b613d34565b60405191965091506131889084908490602001615976565b60405160208183030381529060405293507f07ea52d82345d6e838192107d8fd7123d9c2ec8e916cd0aad13fd2b60db2464488608001518960a00151836040516131d4939291906159a5565b60405180910390a1505050935093915050565b60006060863b80830361320e5760408051600080825260208201909252925092505061328e565b60008060008761ffff1667ffffffffffffffff81111561323057613230614e19565b6040519080825280601f01601f19166020018201604052801561325a576020820181803683370190505b509050600080885160208a018c8f8ff191503d92508783111561327b578792505b828152826000602083013e909450925050505b9550959350505050565b6000808315806132a9575082516020115b156132b957506000905080610be0565b6000838060200190518101906132cf919061568a565b905085156132df57809150613309565b600060055488116132f2576005546132f4565b875b90508082116133035781613305565b805b9350505b5094509492505050565b6000612372605160318486615719565b6000805b8251811015611e8f5760008382815181106133445761334461504e565b602002602001015190508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16116133b3576040517fc0762a5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9150600101613327565b6060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60ff8616016134585786511561341a5786848460405160200161340693929190615a03565b604051602081830303815290604052613451565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050505b9650613527565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe60ff8616016134f0578551156134b25785848460405160200161349e93929190615a03565b6040516020818303038152906040526134e9565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050505b9550613527565b6040517f6780cfaf00000000000000000000000000000000000000000000000000000000815260ff861660048201526024016109bb565b509495939450505050565b60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61ffff8516016136585760228214613599576040517f0dc652a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006135ba6135ac602260028688615719565b6135b591615817565b614010565b6040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e11000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608083901b1660248201529091506034016040516020818303038152906040529150506113c8565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe61ffff851601613779576042821115806136935750606282115b156136ca576040517fc0927c5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006136dd6135ac602260028688615719565b905060006136f26135ac604260228789615719565b905060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbe8501613726866042818a615719565b61372f91615817565b60405160086020938403029190911c9250613760916001916011918391889183916031916002918b918b9101615a2b565b60405160208183030381529060405293505050506113c8565b6040517f4170513000000000000000000000000000000000000000000000000000000000815261ffff851660048201526024016109bb565b60608082516000036137c257915091565b60006137cd846140b6565b90508060ff1660010361387f5760408051600180825281830190925290816020015b60608152602001906001900390816137ef579050509250838360008151811061381a5761381a61504e565b6020908102919091010152604080516001808252818301909252908160200160208202803683370190505091506138528460036141db565b826000815181106138655761386561504e565b602002602001019060ff16908160ff168152505050915091565b8060ff1667ffffffffffffffff81111561389b5761389b614e19565b6040519080825280602002602001820160405280156138c4578160200160208202803683370190505b5091508060ff1667ffffffffffffffff8111156138e3576138e3614e19565b60405190808252806020026020018201604052801561391657816020015b60608152602001906001900390816139015790505b50925060008060ff5b86518310156139ca57600190920191600061393a888561425b565b600294909401939050600061394f89866141db565b90508260ff1660ff03613964578092506139bb565b8260ff168160ff16146139bb577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8486030160006139a38b87846142db565b90506139b18a8a8784614455565b5093909301929150815b5061ffff16929092019161391f565b81830360006139da8985846142db565b90506139e888888584614455565b60005b8660ff168160ff161015613a4957878160ff1681518110613a0e57613a0e61504e565b6020908102919091010180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160ff1690526001016139eb565b50505050505050915091565b60006060853b808303613a7c57604080516000808252602082019092529250925050610be0565b60008060008761ffff1667ffffffffffffffff811115613a9e57613a9e614e19565b6040519080825280601f01601f191660200182016040528015613ac8576020820181803683370190505b509050600080885160208a018d8dfa91503d925087831115613ae8578792505b828152826000602083013e90999098509650505050505050565b73ffffffffffffffffffffffffffffffffffffffff8216613b4f576040517f6b7a931000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114613ba9576040519150601f19603f3d011682016040523d82523d6000602084013e613bae565b606091505b5050905080611e8f576040517f465bc83400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602481018390526044016109bb565b6000613c6a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166145849092919063ffffffff16565b9050805160001480613c8b575080806020019051810190613c8b9190615b24565b611e8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016109bb565b60608160a001518260c00151604051602001612c01929190615b41565b60006060600080613d44856137b1565b9150915060008a604001518b60200151613d5e91906158fb565b90508060ff1667ffffffffffffffff811115613d7c57613d7c614e19565b604051908082528060200260200182016040528015613da5578160200160208202803683370190505b50935060005b8160ff168160ff1610156140015760008c6020015160ff168260ff1610613e005760a08d015160208e0151613de09084615853565b60ff1681518110613df357613df361504e565b6020026020010151613e22565b8c608001518260ff1681518110613e1957613e1961504e565b60200260200101515b60408051602081019091526000808252919250905b8551811015613e8f578360ff16868281518110613e5657613e5661504e565b602002602001015160ff1603613e8757868181518110613e7857613e7861504e565b60200260200101519150613e8f565b600101613e37565b508173ffffffffffffffffffffffffffffffffffffffff1663f42ed2ed8e8e8e8e866040518663ffffffff1660e01b8152600401613ed1959493929190615914565b6020604051808303816000875af1158015613ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f14919061568a565b878460ff1681518110613f2957613f2961504e565b6020026020010181815250506000878460ff1681518110613f4c57613f4c61504e565b60200260200101511115613ff757868360ff1681518110613f6f57613f6f61504e565b6020026020010151600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613fc59190615184565b92505081905550868360ff1681518110613fe157613fe161504e565b602002602001015188613ff49190615184565b97505b5050600101613dab565b50505050965096945050505050565b60006fffffffffffffffffffffffffffffffff8211156140b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f323820626974730000000000000000000000000000000000000000000000000060648201526084016109bb565b5090565b600080805b83518210156141975760019091019060006140d6858461425b565b905060028301925060028161ffff161015614120576040517f04eb6e0c000000000000000000000000000000000000000000000000000000008152600481018490526024016109bb565b600061412c86856141db565b90508060ff1660ff0361416b576040517fd3d3d9bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff82161b83166141885760019485019460ff82161b831792505b5061ffff1691909101906140bb565b835182146141d4576040517f04eb6e0c000000000000000000000000000000000000000000000000000000008152600481018390526024016109bb565b5050919050565b60006141e8826001615184565b83511015614252576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f746f55696e74385f6f75744f66426f756e64730000000000000000000000000060448201526064016109bb565b50016001015190565b6000614268826002615184565b835110156142d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e647300000000000000000000000060448201526064016109bb565b50016002015190565b6060816142e981601f615184565b1015614351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f7700000000000000000000000000000000000060448201526064016109bb565b61435b8284615184565b845110156143c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e647300000000000000000000000000000060448201526064016109bb565b6060821580156143e4576040519150600082526020820160405261444c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561441d578051835260209283019201614405565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b8160ff1660ff03614492576040517fd3d3d9bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061449f8360016158fb565b905060005b84518110156128e85760008582815181106144c1576144c161504e565b602002602001015190508060ff168360ff1603614536578682815181106144ea576144ea61504e565b602002602001015184604051602001614504929190615976565b6040516020818303038152906040528783815181106145255761452561504e565b6020026020010181905250506128e8565b8060ff1660000361457b57828683815181106145545761455461504e565b602002602001019060ff16908160ff1681525050838783815181106145255761452561504e565b506001016144a4565b60606106b78484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516145b89190615b67565b60006040518083038185875af1925050503d80600081146145f5576040519150601f19603f3d011682016040523d82523d6000602084013e6145fa565b606091505b509150915061460b87838387614616565b979650505050505050565b606083156146ac5782516000036146a55773ffffffffffffffffffffffffffffffffffffffff85163b6146a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109bb565b50816106b7565b6106b783838151156146c15781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bb9190614d4b565b82805482825590600052602060002090810192821561476f579160200282015b8281111561476f57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190614715565b506140b29291505b808211156140b25760008155600101614777565b60006020828403121561479d57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146113c857600080fd5b600080600080608085870312156147e357600080fd5b843567ffffffffffffffff8111156147fa57600080fd5b850160c0818803121561480c57600080fd5b966020860135965060408601359560600135945092505050565b6020810160038310614861577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b73ffffffffffffffffffffffffffffffffffffffff81168114611b3357600080fd5b803561489481614867565b919050565b803563ffffffff8116811461489457600080fd5b803567ffffffffffffffff8116811461489457600080fd5b6000806000606084860312156148da57600080fd5b83356148e581614867565b92506148f360208501614899565b9150614901604085016148ad565b90509250925092565b60008060006060848603121561491f57600080fd5b833561492a81614867565b9250602084013561493a81614867565b929592945050506040919091013590565b60008083601f84011261495d57600080fd5b50813567ffffffffffffffff81111561497557600080fd5b6020830191508360208260051b850101111561499057600080fd5b9250929050565b6000806000604084860312156149ac57600080fd5b83356149b781614867565b9250602084013567ffffffffffffffff8111156149d357600080fd5b6149df8682870161494b565b9497909650939450505050565b600080600060608486031215614a0157600080fd5b83359250602084013591506040840135614a1a81614867565b809150509250925092565b60008083601f840112614a3757600080fd5b50813567ffffffffffffffff811115614a4f57600080fd5b60208301915083602082850101111561499057600080fd5b8015158114611b3357600080fd5b60008060008060608587031215614a8b57600080fd5b843567ffffffffffffffff80821115614aa357600080fd5b9086019060e08289031215614ab757600080fd5b90945060208601359080821115614acd57600080fd5b50614ada87828801614a25565b9094509250506040850135614aee81614a67565b939692955090935050565b60005b83811015614b14578181015183820152602001614afc565b50506000910152565b60008151808452614b35816020860160208601614af9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b82518152602080840151908201526060604082015260006106b76060830184614b1d565b60008060008060608587031215614ba157600080fd5b843567ffffffffffffffff811115614bb857600080fd5b614bc487828801614a25565b90989097506020870135966040013595509350505050565b600060208284031215614bee57600080fd5b6113c882614899565b60008060408385031215614c0a57600080fd5b8235614c1581614867565b9150614c2360208401614899565b90509250929050565b60008151808452602080850194506020840160005b83811015614c7357815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614c41565b509495945050505050565b73ffffffffffffffffffffffffffffffffffffffff815116825260ff602082015116602083015260ff604082015116604083015260ff60608201511660608301526000608082015160c06080850152614cda60c0850182614c2c565b905060a083015184820360a0860152614cf38282614c2c565b95945050505050565b6020815260006113c86020830184614c7e565b600080600060608486031215614d2457600080fd5b614d2d84614899565b92506020840135614d3d81614867565b915061490160408501614899565b6020815260006113c86020830184614b1d565b60008060208385031215614d7157600080fd5b823567ffffffffffffffff811115614d8857600080fd5b614d948582860161494b565b90969095509350505050565b600060208284031215614db257600080fd5b5035919050565b815181526020808301519082015260408101610698565b600060208284031215614de257600080fd5b81356113c881614867565b60008060408385031215614e0057600080fd5b8235614e0b81614867565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff81118282101715614e6b57614e6b614e19565b60405290565b60405160e0810167ffffffffffffffff81118282101715614e6b57614e6b614e19565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715614edb57614edb614e19565b604052919050565b803560ff8116811461489457600080fd5b600082601f830112614f0557600080fd5b8135602067ffffffffffffffff821115614f2157614f21614e19565b8160051b614f30828201614e94565b9283528481018201928281019087851115614f4a57600080fd5b83870192505b8483101561460b578235614f6381614867565b82529183019190830190614f50565b600060c08284031215614f8457600080fd5b614f8c614e48565b9050614f9782614889565b8152614fa560208301614ee3565b6020820152614fb660408301614ee3565b6040820152614fc760608301614ee3565b6060820152608082013567ffffffffffffffff80821115614fe757600080fd5b614ff385838601614ef4565b608084015260a084013591508082111561500c57600080fd5b5061501984828501614ef4565b60a08301525092915050565b60006106983683614f72565b60006020828403121561504357600080fd5b81516113c881614867565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa18336030181126150b157600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126150f057600080fd5b83018035915067ffffffffffffffff82111561510b57600080fd5b60200191503681900382131561499057600080fd5b60006020828403121561513257600080fd5b813567ffffffffffffffff81111561514957600080fd5b6106b784828501614f72565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561069857610698615155565b8183823760009101908152919050565b6000602082840312156151b957600080fd5b6113c8826148ad565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8616815260806020820152600061523b6080830186886151c2565b604083019490945250606001529392505050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18336030181126150b157600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff418336030181126150b157600080fd5b6000602082840312156152c957600080fd5b6113c882614ee3565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261530757600080fd5b830160208101925035905067ffffffffffffffff81111561532757600080fd5b8060051b360382131561499057600080fd5b8183526000602080850194508260005b85811015614c7357813561535c81614867565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101615349565b60208082528181018390526000906040808401600586901b8501820187855b88811015615521577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08089850301855282357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18c360301811261540557600080fd5b8b0163ffffffff61541582614899565b168552878101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4182360301811261544c57600080fd5b85890188905201803561545e81614867565b73ffffffffffffffffffffffffffffffffffffffff1685880152615483818901614ee3565b606060ff808316828901526154998a8501614ee3565b92506080818416818a01526154af838601614ee3565b935060a09250818416838a01526154c8818601866152d2565b60c08b810152945091506154e3905061010089018483615339565b9250506154f2818401846152d2565b93509050838783030160e088015261550b828483615339565b978a0197965050509287019250506001016153a3565b509098975050505050505050565b600082601f83011261554057600080fd5b813567ffffffffffffffff81111561555a5761555a614e19565b61558b60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614e94565b8181528460208386010111156155a057600080fd5b816020850160208301376000918101602001919091529392505050565b600060e082360312156155cf57600080fd5b6155d7614e71565b6155e0836148ad565b81526155ee60208401614899565b60208201526155ff60408401614889565b604082015261561060608401614899565b60608201526080830135608082015260a083013560a082015260c083013567ffffffffffffffff81111561564357600080fd5b61564f3682860161552f565b60c08301525092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006106b76040830184614b1d565b60006020828403121561569c57600080fd5b5051919050565b600060ff8216806156b6576156b6615155565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b73ffffffffffffffffffffffffffffffffffffffff8416815263ffffffff831660208201526060604082015260006106b46060830184614c7e565b6000808585111561572957600080fd5b8386111561573657600080fd5b5050820193919092039150565b7fff0000000000000000000000000000000000000000000000000000000000000081358181169160018510156157835780818660010360031b1b83161692505b505092915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156157835760049490940360031b84901b1690921692915050565b7fffffffffffffffff00000000000000000000000000000000000000000000000081358181169160088510156157835760089490940360031b84901b1690921692915050565b80356020831015610698577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b60ff828116828216039081111561069857610698615155565b600060ff8316806158a6577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b8060ff84160491505092915050565b7fffff00000000000000000000000000000000000000000000000000000000000081358181169160028510156157835760029490940360031b84901b1690921692915050565b60ff818116838216019081111561069857610698615155565b73ffffffffffffffffffffffffffffffffffffffff861681526080602082015260006159436080830187614b1d565b82810360408401526159568186886151c2565b9050828103606084015261596a8185614b1d565b98975050505050505050565b60008351615988818460208801614af9565b83519083019061599c818360208801614af9565b01949350505050565b6060815260006159b86060830186614c2c565b602083820360208501526159cc8287614c2c565b84810360408601528551808252602080880194509091019060005b81811015615521578451835293830193918301916001016159e7565b60008451615a15818460208901614af9565b8201838582376000930192835250909392505050565b60007fff00000000000000000000000000000000000000000000000000000000000000808c60f81b1683527fffff000000000000000000000000000000000000000000000000000000000000808c60f01b166001850152818b60f81b1660038501527fffffffffffffffffffffffffffffffff000000000000000000000000000000008a60801b166004850152818960f81b166014850152808860f01b16601585015250808660f81b16601784015250615b0c601883018560801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000169052565b50602881019190915260480198975050505050505050565b600060208284031215615b3657600080fd5b81516113c881614a67565b82815260008251615b59816020850160208701614af9565b919091016020019392505050565b600082516150b1818460208701614af956fea2646970667358221220a08f921b20f6954702229b9b59cb4577e9b30e40b354bc3a8c116713153fa0dd64736f6c634300081600330000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b0000000000000000000000000000000000000000000000000000000000030d400000000000000000000000000000000000000000000000001bc16d674ec80000

Deployed Bytecode

0x60806040526004361061019a5760003560e01c80637620fd01116100e1578063d15b0d491161008a578063f0f4426011610064578063f0f442601461052c578063f2fde38b1461054c578063faaebd211461056c578063fd9be5221461059957600080fd5b8063d15b0d49146104bf578063d80e9bd9146104df578063ea69d69d1461050c57600080fd5b80639c33abf7116100bb5780639c33abf714610452578063ab750e751461047f578063c85f4b4e1461049f57600080fd5b80637620fd01146103935780638da5cb5b146103f05780638eb0bf301461042557600080fd5b80633c782a5211610143578063594924da1161011d578063594924da1461033e5780636750cd4c1461035e578063715018a61461037e57600080fd5b80633c782a52146102a55780634389e58f146102e357806354fd4d501461031157600080fd5b80631fb51225116101745780631fb5122514610217578063200175f71461026357806320efd7221461028557600080fd5b806301ffc9a7146101a6578063052368ca146101db5780631881d94d146101fb57600080fd5b366101a157005b600080fd5b3480156101b257600080fd5b506101c66101c136600461478b565b6105b9565b60405190151581526020015b60405180910390f35b3480156101e757600080fd5b506101c66101f63660046147cd565b61069e565b34801561020757600080fd5b5060026040516101d29190614826565b34801561022357600080fd5b506102556102323660046148c5565b600260209081526000938452604080852082529284528284209052825290205481565b6040519081526020016101d2565b34801561026f57600080fd5b5061028361027e36600461490a565b6106bf565b005b34801561029157600080fd5b506102836102a0366004614997565b61086c565b3480156102b157600080fd5b506102556102c03660046149ec565b600360209081526000938452604080852082529284528284209052825290205481565b3480156102ef57600080fd5b506103036102fe366004614a75565b6109d3565b6040516101d2929190614b67565b34801561031d57600080fd5b5060408051600a8152600060208201526002918101919091526060016101d2565b34801561034a57600080fd5b50610283610359366004614b8b565b610be9565b34801561036a57600080fd5b506101c6610379366004614bdc565b610ec3565b34801561038a57600080fd5b50610283610ece565b34801561039f57600080fd5b506103c460065460055473ffffffffffffffffffffffffffffffffffffffff90911691565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152016101d2565b3480156103fc57600080fd5b5060005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101d2565b34801561043157600080fd5b50610445610440366004614bf7565b610ee2565b6040516101d29190614cfc565b34801561045e57600080fd5b5061047261046d366004614d0f565b61132f565b6040516101d29190614d4b565b34801561048b57600080fd5b5061028361049a366004614b8b565b6113cf565b3480156104ab57600080fd5b506102836104ba366004614d5e565b61145a565b3480156104cb57600080fd5b506102836104da366004614da0565b611644565b3480156104eb57600080fd5b506104ff6104fa366004614a75565b6116d2565b6040516101d29190614db9565b34801561051857600080fd5b50610445610527366004614bf7565b611844565b34801561053857600080fd5b50610283610547366004614dd0565b611a04565b34801561055857600080fd5b50610283610567366004614dd0565b611a7f565b34801561057857600080fd5b50610255610587366004614dd0565b60046020526000908152604090205481565b3480156105a557600080fd5b506102836105b4366004614ded565b611b36565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f97f0258400000000000000000000000000000000000000000000000000000000148061064c57507fffffffff0000000000000000000000000000000000000000000000000000000082167fb6e9ace300000000000000000000000000000000000000000000000000000000145b8061069857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006106b46106ac86615025565b858585611cab565b90505b949350505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610710576040517f96830d1e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff167f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b73ffffffffffffffffffffffffffffffffffffffff1663e1758bd86040518163ffffffff1660e01b8152600401602060405180830381865afa158015610792573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b69190615031565b73ffffffffffffffffffffffffffffffffffffffff1603610803576040517fb77f504400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61080e838383611e21565b6040805173ffffffffffffffffffffffffffffffffffffffff8086168252841660208201529081018290527fe081464b7278501267de69fa85b7b9560b0ae05d5fbfaab9b1986c70356e2efe906060015b60405180910390a1505050565b7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b73ffffffffffffffffffffffffffffffffffffffff1633146108db576040517f467409c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b818110156109cd57368383838181106108f9576108f961504e565b905060200281019061090b919061507d565b905061092261091d6020830183614bdc565b611e94565b60016109346040830160208401614bdc565b63ffffffff16036109745761096f61094f6020830183614bdc565b8661095d60408501856150bb565b81019061096a9190615120565b611edb565b6109c4565b6109846040820160208301614bdc565b6040517f0cb84e8200000000000000000000000000000000000000000000000000000000815263ffffffff90911660048201526024015b60405180910390fd5b506001016108de565b50505050565b604080518082019091526000808252602082015260607f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b73ffffffffffffffffffffffffffffffffffffffff163314610a58576040517f467409c300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6080860135610a89610a706060890160408a01614dd0565b73ffffffffffffffffffffffffffffffffffffffff1690565b14610ac0576040517fa4884a5900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610ace888888611f24565b9092509050600080610b00610ae960608c0160408d01614dd0565b610af960808d0160608e01614bdc565b858a611fad565b9092509050610b0f8284615184565b9250610b1e60c08b018b6150bb565b604051610b2c929190615197565b6040518091039020600260008c6040016020810190610b4b9190614dd0565b73ffffffffffffffffffffffffffffffffffffffff1681526020810191909152604001600090812090610b8460808e0160608f01614bdc565b63ffffffff168152602080820192909252604001600090812091610baa908e018e6151a7565b67ffffffffffffffff16815260208082019290925260409081016000209290925581518083019092529381529283015250925090505b94509492505050565b60518314610c23576040517f864d08b300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001610c2f858561213b565b60ff1614610c69576040517f7952a82f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000766863ffffffff16610c9a858561215d565b63ffffffff1614610cd7576040517f3e96df1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610ce38585612180565b90506000610cf18686612192565b90506000610cff87876121a2565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260026020908152604080832063ffffffff87168452825280832067ffffffffffffffff851684529091529020549091508514610d83576040517f660e96ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610d8f8484610ee2565b9050610db4818989604051610da5929190615197565b604051809103902088886121c5565b600060405180606001604052808563ffffffff168152602001610dd78b8b612362565b815267ffffffffffffffff858116602092830152604080517fa825d747000000000000000000000000000000000000000000000000000000008152845163ffffffff16600482015292840151602484015283015116604482015273ffffffffffffffffffffffffffffffffffffffff8781166064830152608482018990529192507f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b9091169063a825d7479060a401600060405180830381600087803b158015610ea057600080fd5b505af1158015610eb4573d6000803e3d6000fd5b50505050505050505050505050565b60006106988261237b565b610ed66123fa565b610ee0600061247b565b565b6040805160c0810182526000808252602080830182905282840182905260608084018390526080840181905260a084015263ffffffff85168083527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49825284832073ffffffffffffffffffffffffffffffffffffffff888116855260018452868520928552919092529390912080549293919290911680610f9a57825473ffffffffffffffffffffffffffffffffffffffff16610f9c565b805b73ffffffffffffffffffffffffffffffffffffffff168452815474010000000000000000000000000000000000000000900460ff1661108e57825474010000000000000000000000000000000000000000900460ff1615611089578260010180548060200260200160405190810160405280929190818152602001828054801561105c57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611031575b50505050506080850152825474010000000000000000000000000000000000000000900460ff1660208501525b611144565b815474010000000000000000000000000000000000000000900460ff90811614611144578160010180548060200260200160405190810160405280929190818152602001828054801561111757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116110ec575b50505050506080850152815474010000000000000000000000000000000000000000900460ff1660208501525b81547501000000000000000000000000000000000000000000900460ff166112435782547501000000000000000000000000000000000000000000900460ff161561123e57826002018054806020026020016040519081016040528092919081815260200182805480156111ee57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111c3575b505050505060a0850152825460ff75010000000000000000000000000000000000000000008204811660408701527601000000000000000000000000000000000000000000009091041660608501525b61131d565b81547501000000000000000000000000000000000000000000900460ff9081161461131d57816002018054806020026020016040519081016040528092919081815260200182805480156112cd57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116112a2575b505050505060a0850152815460ff75010000000000000000000000000000000000000000008204811660408701527601000000000000000000000000000000000000000000009091041660608501525b611326846124f0565b50505092915050565b60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff63ffffffff83160161138e576113688385610ee2565b6040516020016113789190614cfc565b60405160208183030381529060405290506113c8565b6040517f0cb84e8200000000000000000000000000000000000000000000000000000000815263ffffffff831660048201526024016109bb565b9392505050565b806003600086866040516113e4929190615197565b60408051918290039091208252602080830193909352908101600090812086825283528181203380835293528190209290925590517f04708e5dfef6005d6d646eb761e3b9e412e1cc5749fc9d884bca441cc7a952589161144c91879087908790879061520b565b60405180910390a150505050565b6114626123fa565b60005b8181101561160657368383838181106114805761148061504e565b9050602002810190611492919061524f565b905060ff6114a36020830183615283565b6114b49060408101906020016152b7565b60ff16036114ee576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60ff6114fd6020830183615283565b61150e9060608101906040016152b7565b60ff1603611548576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115666115586020830183615283565b61156190615025565b6124f0565b60006115756020830183615283565b611583906020810190614dd0565b73ffffffffffffffffffffffffffffffffffffffff16036115d0576040517f76df55a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115fd60006115e26020840184614bdc565b6115ef6020850185615283565b6115f890615025565b612541565b50600101611465565b507f65edb7dc0f21ba15c998f8bd220ea9fec30757ff9fb07696c634bcce00ce6f348282604051611638929190615384565b60405180910390a15050565b61164c6123fa565b600554811115611696576005546040517fb79d12630000000000000000000000000000000000000000000000000000000081526109bb918391600401918252602082015260400190565b60058190556040518181527f491ff913b5444f4136b0d4075f020cfe3a5f60de926ec0b091612401a22b7842906020015b60405180910390a150565b60408051808201909152600080825260208201526000806116f386866128f0565b9092509050600061170a6060890160408a01614dd0565b9050600061171e60808a0160608b01614bdc565b9050600061172c8383610ee2565b9050600061175c82856117466117418f6155bd565b612b31565b8e8060c0019061175691906150bb565b8a612c17565b82516040517fc8f8dcd100000000000000000000000000000000000000000000000000000000815291925073ffffffffffffffffffffffffffffffffffffffff169063c8f8dcd1906117b49087908a9060040161565b565b602060405180830381865afa1580156117d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117f5919061568a565b6117ff9082615184565b90506000806118108686858d612deb565b909250905061181f8284615184565b6040805180820190915290815260208101919091529c9b505050505050505050505050565b6040805160c0810182526000808252602082018190529181018290526060808201929092526080810182905260a081019190915273ffffffffffffffffffffffffffffffffffffffff808416600090815260016020818152604080842063ffffffff88168552825292839020835160c0810185528154958616815260ff740100000000000000000000000000000000000000008704811682850152750100000000000000000000000000000000000000000087048116828701527601000000000000000000000000000000000000000000009096049095166060860152918201805484518184028101840190955280855292936080860193909283018282801561198457602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311611959575b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156119f357602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116119c8575b505050505081525050905092915050565b611a0c6123fa565b600680547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f3c864541ef71378c6229510ed90f376565ee42d9c5e0904a984a9e863e6db44f906020016116c7565b611a876123fa565b73ffffffffffffffffffffffffffffffffffffffff8116611b2a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016109bb565b611b338161247b565b50565b3360009081526004602052604090205480821115611b8a576040517fb79d126300000000000000000000000000000000000000000000000000000000815260048101839052602481018290526044016109bb565b336000908152600460208181526040808420868603905580517fe1758bd800000000000000000000000000000000000000000000000000000000815290517f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b73ffffffffffffffffffffffffffffffffffffffff169363e1758bd89383820193909291908290030181865afa158015611c27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4b9190615031565b9050611c58818585612f2f565b6040805133815273ffffffffffffffffffffffffffffffffffffffff861660208201529081018490527f820b7fd51bf79c54350bab98400651b3314ff6e79b33528821871d94a66698839060600161144c565b602084015160009060ff1615611d645760005b856020015160ff168160ff161015611d4c57611d3686608001518260ff1681518110611cec57611cec61504e565b6020026020010151868686600092835260036020908152604080852093855292815282842073ffffffffffffffffffffffffffffffffffffffff9095168452939093529020541490565b611d445760009150506106b7565b600101611cbe565b50846040015160ff16600003611d64575060016106b7565b606085015160005b866040015160ff168160ff161015611e1457611de48760a001518260ff1681518110611d9a57611d9a61504e565b6020026020010151878787600092835260036020908152604080852093855292815282842073ffffffffffffffffffffffffffffffffffffffff9095168452939093529020541490565b15611e0c5781611df3816156a3565b9250508160ff16600003611e0c576001925050506106b7565b600101611d6c565b5060009695505050505050565b73ffffffffffffffffffffffffffffffffffffffff8216611e6e576040517f6b7a931000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611e8f73ffffffffffffffffffffffffffffffffffffffff84168383612f5f565b505050565b611e9d8161237b565b611b33576040517f0ff03e5400000000000000000000000000000000000000000000000000000000815263ffffffff821660048201526024016109bb565b611ee6828483612541565b611ef08284610ee2565b507fe8e2a5b92fc69ac50188ea142042492be8e8c34febb10b2cd02983684336e14282848360405161085f939291906156de565b60606000806000611f3586866128f0565b90925090506000611f5f611f4f60608a0160408b01614dd0565b61044060808b0160608c01614bdc565b8051909150611f7e90611f7860608b0160408c01614dd0565b85612fec565b9350600080611f8e838b8661311f565b9092509050611f9d8287615184565b909a909950975050505050505050565b600654600090819073ffffffffffffffffffffffffffffffffffffffff1615610be05760405173ffffffffffffffffffffffffffffffffffffffff8716602482015263ffffffff8616604482015260648101859052831515608482015260009060a401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052602080820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd51c54860000000000000000000000000000000000000000000000000000000017905260065491925060009182916120d79173ffffffffffffffffffffffffffffffffffffffff16907f0000000000000000000000000000000000000000000000000000000000030d40908490876131e7565b915091506120e787878484613298565b9095509350841561212f5760065473ffffffffffffffffffffffffffffffffffffffff1660009081526004602052604081208054879290612129908490615184565b90915550505b50505094509492505050565b600061214a6001828486615719565b61215391615743565b60f81c9392505050565b600061216d6031602d8486615719565b6121769161578b565b60e01c9392505050565b60006113c861218f8484613313565b90565b600061216d600d60098486615719565b60006121b2600960018486615719565b6121bb916157d1565b60c01c9392505050565b6121d184848484611cab565b612207576040517f28ca4b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602084015160ff16156122b25760005b846020015160ff168160ff1610156122b057600084815260036020908152604080832086845290915281206080870151805191929160ff851690811061225f5761225f61504e565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009055806001019050612217565b505b604084015160ff16156109cd5760005b846040015160ff168160ff16101561235b576000848152600360209081526040808320868452909152812060a0870151805191929160ff851690811061230a5761230a61504e565b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600090558060010190506122c2565b5050505050565b6000612372602d600d8486615719565b6113c891615817565b63ffffffff811660009081527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb4960205260408120805474010000000000000000000000000000000000000000900460ff161515806113c8575054760100000000000000000000000000000000000000000000900460ff16151592915050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ee0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109bb565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b602081015160ff1615801561250a5750606081015160ff16155b15611b33576040517f9b5f9f7a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b602081015160ff908116148061255c5750602081015160ff16155b156125a3576080810151511561259e576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612622565b806020015160ff168160800151511415806125de575060026125c7600160ff615853565b6125d1919061586c565b60ff16816020015160ff16115b15612615576040517f55a01c0200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6126228160800151613323565b604081015160ff908116148061263d5750604081015160ff16155b156126c35760a0810151511561267f576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081015160ff16156126be576040517ff92940be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61279a565b806040015160ff168160a00151511415806126fe575060026126e7600160ff615853565b6126f1919061586c565b60ff16816040015160ff16115b15612735576040517fe35436c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606081015160ff1615806127565750806040015160ff16816060015160ff16115b1561278d576040517ff92940be00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61279a8160a00151613323565b73ffffffffffffffffffffffffffffffffffffffff838116600090815260016020818152604080842063ffffffff881685528252928390208551815487840151958801516060890151929097167fffffffffffffffffffffff000000000000000000000000000000000000000000909116177401000000000000000000000000000000000000000060ff96871602177fffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffffff167501000000000000000000000000000000000000000000968616969096027fffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffffff169590951776010000000000000000000000000000000000000000000094909516939093029390931782556080840151805185946128cc9385019201906146f5565b5060a082015180516128e89160028401916020909101906146f5565b505050505050565b6060806002831015612931576040517f6592671c000000000000000000000000000000000000000000000000000000008152600060048201526024016109bb565b60006129406002828688615719565b612949916158b5565b60f01c905060027ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8201612b1a578060005b86831015612aa657600061299460018501858a8c615719565b61299d91615743565b60f81c905060008190036129e0576040517f6780cfaf000000000000000000000000000000000000000000000000000000008152600060048201526024016109bb565b8160ff166000036129f357809150612a30565b8160ff168160ff1614612a3057366000612a0f86868c8e615719565b91509150612a2089898685856133bd565b9099509750859450919250829150505b6001840193600090612a4790600301868b8d615719565b612a50916158b5565b60f01c90506000819003612a93576040517f6592671c000000000000000000000000000000000000000000000000000000008152600481018690526024016109bb565b8060020161ffff1685019450505061297b565b828714612ae2576040517f6592671c000000000000000000000000000000000000000000000000000000008152600481018490526024016109bb565b6002871115612b1357366000612afa85858b8d615719565b91509150612b0b88888585856133bd565b909850965050505b5050612b28565b612b25828787613532565b93505b50509250929050565b8051602080830151604080850151606080870151608088015193517f01000000000000000000000000000000000000000000000000000000000000009681019690965260c09690961b7fffffffffffffffff00000000000000000000000000000000000000000000000016602186015260e093841b7fffffffff00000000000000000000000000000000000000000000000000000000908116602987015273ffffffffffffffffffffffffffffffffffffffff909216602d8601529490921b909116604d83015260518201526071015b6040516020818303038152906040529050919050565b6000806000612c25846137b1565b91509150600089604001518a60200151612c3f91906158fb565b905060005b8160ff168160ff161015612ddd5760008b6020015160ff168260ff1610612c995760a08c015160208d0151612c799084615853565b60ff1681518110612c8c57612c8c61504e565b6020026020010151612cbb565b8b608001518260ff1681518110612cb257612cb261504e565b60200260200101515b60408051602081019091526000808252919250905b8551811015612d28578360ff16868281518110612cef57612cef61504e565b602002602001015160ff1603612d2057868181518110612d1157612d1161504e565b60200260200101519150612d28565b600101612cd0565b506040517ffdb9b0f100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063fdb9b0f190612d83908f908f908f908f908890600401615914565b602060405180830381865afa158015612da0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dc4919061568a565b612dce9088615184565b96505050806001019050612c44565b505050509695505050505050565b600654600090819073ffffffffffffffffffffffffffffffffffffffff1615610be05760405173ffffffffffffffffffffffffffffffffffffffff8716602482015263ffffffff8616604482015260648101859052831515608482015260009060a401604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152919052602080820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fd4244221000000000000000000000000000000000000000000000000000000001790526006549192506000918291612f139173ffffffffffffffffffffffffffffffffffffffff16907f0000000000000000000000000000000000000000000000000000000000030d409086613a55565b91509150612f2387878484613298565b94509450505050610be0565b73ffffffffffffffffffffffffffffffffffffffff8316612f5457611e8f8282613b02565b611e8f838383611e21565b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611e8f908490613c08565b6040517fc015bb7d00000000000000000000000000000000000000000000000000000000815260009073ffffffffffffffffffffffffffffffffffffffff85169063c015bb7d90613043908690869060040161565b565b6020604051808303816000875af1158015613062573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613086919061568a565b905080156130c95773ffffffffffffffffffffffffffffffffffffffff8416600090815260046020526040812080548392906130c3908490615184565b90915550505b6040805173ffffffffffffffffffffffffffffffffffffffff86168152602081018390527f61ed099e74a97a1d7f8bb0952a88ca8b7b8ebd00c126ea04671f92a81213318a910160405180910390a19392505050565b6000606081613130611741866155bd565b90506000613145613140876155bd565b613d17565b905060606131708861315c89840160408b01614dd0565b8561316a60c08c018c6150bb565b8b613d34565b60405191965091506131889084908490602001615976565b60405160208183030381529060405293507f07ea52d82345d6e838192107d8fd7123d9c2ec8e916cd0aad13fd2b60db2464488608001518960a00151836040516131d4939291906159a5565b60405180910390a1505050935093915050565b60006060863b80830361320e5760408051600080825260208201909252925092505061328e565b60008060008761ffff1667ffffffffffffffff81111561323057613230614e19565b6040519080825280601f01601f19166020018201604052801561325a576020820181803683370190505b509050600080885160208a018c8f8ff191503d92508783111561327b578792505b828152826000602083013e909450925050505b9550959350505050565b6000808315806132a9575082516020115b156132b957506000905080610be0565b6000838060200190518101906132cf919061568a565b905085156132df57809150613309565b600060055488116132f2576005546132f4565b875b90508082116133035781613305565b805b9350505b5094509492505050565b6000612372605160318486615719565b6000805b8251811015611e8f5760008382815181106133445761334461504e565b602002602001015190508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16116133b3576040517fc0762a5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9150600101613327565b6060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60ff8616016134585786511561341a5786848460405160200161340693929190615a03565b604051602081830303815290604052613451565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050505b9650613527565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe60ff8616016134f0578551156134b25785848460405160200161349e93929190615a03565b6040516020818303038152906040526134e9565b83838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050505b9550613527565b6040517f6780cfaf00000000000000000000000000000000000000000000000000000000815260ff861660048201526024016109bb565b509495939450505050565b60607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61ffff8516016136585760228214613599576040517f0dc652a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006135ba6135ac602260028688615719565b6135b591615817565b614010565b6040517f0100000000000000000000000000000000000000000000000000000000000000602082018190527e11000000000000000000000000000000000000000000000000000000000000602183015260238201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608083901b1660248201529091506034016040516020818303038152906040529150506113c8565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe61ffff851601613779576042821115806136935750606282115b156136ca576040517fc0927c5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006136dd6135ac602260028688615719565b905060006136f26135ac604260228789615719565b905060007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbe8501613726866042818a615719565b61372f91615817565b60405160086020938403029190911c9250613760916001916011918391889183916031916002918b918b9101615a2b565b60405160208183030381529060405293505050506113c8565b6040517f4170513000000000000000000000000000000000000000000000000000000000815261ffff851660048201526024016109bb565b60608082516000036137c257915091565b60006137cd846140b6565b90508060ff1660010361387f5760408051600180825281830190925290816020015b60608152602001906001900390816137ef579050509250838360008151811061381a5761381a61504e565b6020908102919091010152604080516001808252818301909252908160200160208202803683370190505091506138528460036141db565b826000815181106138655761386561504e565b602002602001019060ff16908160ff168152505050915091565b8060ff1667ffffffffffffffff81111561389b5761389b614e19565b6040519080825280602002602001820160405280156138c4578160200160208202803683370190505b5091508060ff1667ffffffffffffffff8111156138e3576138e3614e19565b60405190808252806020026020018201604052801561391657816020015b60608152602001906001900390816139015790505b50925060008060ff5b86518310156139ca57600190920191600061393a888561425b565b600294909401939050600061394f89866141db565b90508260ff1660ff03613964578092506139bb565b8260ff168160ff16146139bb577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8486030160006139a38b87846142db565b90506139b18a8a8784614455565b5093909301929150815b5061ffff16929092019161391f565b81830360006139da8985846142db565b90506139e888888584614455565b60005b8660ff168160ff161015613a4957878160ff1681518110613a0e57613a0e61504e565b6020908102919091010180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0160ff1690526001016139eb565b50505050505050915091565b60006060853b808303613a7c57604080516000808252602082019092529250925050610be0565b60008060008761ffff1667ffffffffffffffff811115613a9e57613a9e614e19565b6040519080825280601f01601f191660200182016040528015613ac8576020820181803683370190505b509050600080885160208a018d8dfa91503d925087831115613ae8578792505b828152826000602083013e90999098509650505050505050565b73ffffffffffffffffffffffffffffffffffffffff8216613b4f576040517f6b7a931000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff168260405160006040518083038185875af1925050503d8060008114613ba9576040519150601f19603f3d011682016040523d82523d6000602084013e613bae565b606091505b5050905080611e8f576040517f465bc83400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84166004820152602481018390526044016109bb565b6000613c6a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166145849092919063ffffffff16565b9050805160001480613c8b575080806020019051810190613c8b9190615b24565b611e8f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016109bb565b60608160a001518260c00151604051602001612c01929190615b41565b60006060600080613d44856137b1565b9150915060008a604001518b60200151613d5e91906158fb565b90508060ff1667ffffffffffffffff811115613d7c57613d7c614e19565b604051908082528060200260200182016040528015613da5578160200160208202803683370190505b50935060005b8160ff168160ff1610156140015760008c6020015160ff168260ff1610613e005760a08d015160208e0151613de09084615853565b60ff1681518110613df357613df361504e565b6020026020010151613e22565b8c608001518260ff1681518110613e1957613e1961504e565b60200260200101515b60408051602081019091526000808252919250905b8551811015613e8f578360ff16868281518110613e5657613e5661504e565b602002602001015160ff1603613e8757868181518110613e7857613e7861504e565b60200260200101519150613e8f565b600101613e37565b508173ffffffffffffffffffffffffffffffffffffffff1663f42ed2ed8e8e8e8e866040518663ffffffff1660e01b8152600401613ed1959493929190615914565b6020604051808303816000875af1158015613ef0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613f14919061568a565b878460ff1681518110613f2957613f2961504e565b6020026020010181815250506000878460ff1681518110613f4c57613f4c61504e565b60200260200101511115613ff757868360ff1681518110613f6f57613f6f61504e565b6020026020010151600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254613fc59190615184565b92505081905550868360ff1681518110613fe157613fe161504e565b602002602001015188613ff49190615184565b97505b5050600101613dab565b50505050965096945050505050565b60006fffffffffffffffffffffffffffffffff8211156140b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203160448201527f323820626974730000000000000000000000000000000000000000000000000060648201526084016109bb565b5090565b600080805b83518210156141975760019091019060006140d6858461425b565b905060028301925060028161ffff161015614120576040517f04eb6e0c000000000000000000000000000000000000000000000000000000008152600481018490526024016109bb565b600061412c86856141db565b90508060ff1660ff0361416b576040517fd3d3d9bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600160ff82161b83166141885760019485019460ff82161b831792505b5061ffff1691909101906140bb565b835182146141d4576040517f04eb6e0c000000000000000000000000000000000000000000000000000000008152600481018390526024016109bb565b5050919050565b60006141e8826001615184565b83511015614252576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f746f55696e74385f6f75744f66426f756e64730000000000000000000000000060448201526064016109bb565b50016001015190565b6000614268826002615184565b835110156142d2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f746f55696e7431365f6f75744f66426f756e647300000000000000000000000060448201526064016109bb565b50016002015190565b6060816142e981601f615184565b1015614351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f736c6963655f6f766572666c6f7700000000000000000000000000000000000060448201526064016109bb565b61435b8284615184565b845110156143c5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f736c6963655f6f75744f66426f756e647300000000000000000000000000000060448201526064016109bb565b6060821580156143e4576040519150600082526020820160405261444c565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561441d578051835260209283019201614405565b5050858452601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016604052505b50949350505050565b8160ff1660ff03614492576040517fd3d3d9bc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600061449f8360016158fb565b905060005b84518110156128e85760008582815181106144c1576144c161504e565b602002602001015190508060ff168360ff1603614536578682815181106144ea576144ea61504e565b602002602001015184604051602001614504929190615976565b6040516020818303038152906040528783815181106145255761452561504e565b6020026020010181905250506128e8565b8060ff1660000361457b57828683815181106145545761455461504e565b602002602001019060ff16908160ff1681525050838783815181106145255761452561504e565b506001016144a4565b60606106b78484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516145b89190615b67565b60006040518083038185875af1925050503d80600081146145f5576040519150601f19603f3d011682016040523d82523d6000602084013e6145fa565b606091505b509150915061460b87838387614616565b979650505050505050565b606083156146ac5782516000036146a55773ffffffffffffffffffffffffffffffffffffffff85163b6146a5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109bb565b50816106b7565b6106b783838151156146c15781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109bb9190614d4b565b82805482825590600052602060002090810192821561476f579160200282015b8281111561476f57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190614715565b506140b29291505b808211156140b25760008155600101614777565b60006020828403121561479d57600080fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146113c857600080fd5b600080600080608085870312156147e357600080fd5b843567ffffffffffffffff8111156147fa57600080fd5b850160c0818803121561480c57600080fd5b966020860135965060408601359560600135945092505050565b6020810160038310614861577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b91905290565b73ffffffffffffffffffffffffffffffffffffffff81168114611b3357600080fd5b803561489481614867565b919050565b803563ffffffff8116811461489457600080fd5b803567ffffffffffffffff8116811461489457600080fd5b6000806000606084860312156148da57600080fd5b83356148e581614867565b92506148f360208501614899565b9150614901604085016148ad565b90509250925092565b60008060006060848603121561491f57600080fd5b833561492a81614867565b9250602084013561493a81614867565b929592945050506040919091013590565b60008083601f84011261495d57600080fd5b50813567ffffffffffffffff81111561497557600080fd5b6020830191508360208260051b850101111561499057600080fd5b9250929050565b6000806000604084860312156149ac57600080fd5b83356149b781614867565b9250602084013567ffffffffffffffff8111156149d357600080fd5b6149df8682870161494b565b9497909650939450505050565b600080600060608486031215614a0157600080fd5b83359250602084013591506040840135614a1a81614867565b809150509250925092565b60008083601f840112614a3757600080fd5b50813567ffffffffffffffff811115614a4f57600080fd5b60208301915083602082850101111561499057600080fd5b8015158114611b3357600080fd5b60008060008060608587031215614a8b57600080fd5b843567ffffffffffffffff80821115614aa357600080fd5b9086019060e08289031215614ab757600080fd5b90945060208601359080821115614acd57600080fd5b50614ada87828801614a25565b9094509250506040850135614aee81614a67565b939692955090935050565b60005b83811015614b14578181015183820152602001614afc565b50506000910152565b60008151808452614b35816020860160208601614af9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b82518152602080840151908201526060604082015260006106b76060830184614b1d565b60008060008060608587031215614ba157600080fd5b843567ffffffffffffffff811115614bb857600080fd5b614bc487828801614a25565b90989097506020870135966040013595509350505050565b600060208284031215614bee57600080fd5b6113c882614899565b60008060408385031215614c0a57600080fd5b8235614c1581614867565b9150614c2360208401614899565b90509250929050565b60008151808452602080850194506020840160005b83811015614c7357815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101614c41565b509495945050505050565b73ffffffffffffffffffffffffffffffffffffffff815116825260ff602082015116602083015260ff604082015116604083015260ff60608201511660608301526000608082015160c06080850152614cda60c0850182614c2c565b905060a083015184820360a0860152614cf38282614c2c565b95945050505050565b6020815260006113c86020830184614c7e565b600080600060608486031215614d2457600080fd5b614d2d84614899565b92506020840135614d3d81614867565b915061490160408501614899565b6020815260006113c86020830184614b1d565b60008060208385031215614d7157600080fd5b823567ffffffffffffffff811115614d8857600080fd5b614d948582860161494b565b90969095509350505050565b600060208284031215614db257600080fd5b5035919050565b815181526020808301519082015260408101610698565b600060208284031215614de257600080fd5b81356113c881614867565b60008060408385031215614e0057600080fd5b8235614e0b81614867565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160c0810167ffffffffffffffff81118282101715614e6b57614e6b614e19565b60405290565b60405160e0810167ffffffffffffffff81118282101715614e6b57614e6b614e19565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715614edb57614edb614e19565b604052919050565b803560ff8116811461489457600080fd5b600082601f830112614f0557600080fd5b8135602067ffffffffffffffff821115614f2157614f21614e19565b8160051b614f30828201614e94565b9283528481018201928281019087851115614f4a57600080fd5b83870192505b8483101561460b578235614f6381614867565b82529183019190830190614f50565b600060c08284031215614f8457600080fd5b614f8c614e48565b9050614f9782614889565b8152614fa560208301614ee3565b6020820152614fb660408301614ee3565b6040820152614fc760608301614ee3565b6060820152608082013567ffffffffffffffff80821115614fe757600080fd5b614ff385838601614ef4565b608084015260a084013591508082111561500c57600080fd5b5061501984828501614ef4565b60a08301525092915050565b60006106983683614f72565b60006020828403121561504357600080fd5b81516113c881614867565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa18336030181126150b157600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126150f057600080fd5b83018035915067ffffffffffffffff82111561510b57600080fd5b60200191503681900382131561499057600080fd5b60006020828403121561513257600080fd5b813567ffffffffffffffff81111561514957600080fd5b6106b784828501614f72565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561069857610698615155565b8183823760009101908152919050565b6000602082840312156151b957600080fd5b6113c8826148ad565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b73ffffffffffffffffffffffffffffffffffffffff8616815260806020820152600061523b6080830186886151c2565b604083019490945250606001529392505050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18336030181126150b157600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff418336030181126150b157600080fd5b6000602082840312156152c957600080fd5b6113c882614ee3565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261530757600080fd5b830160208101925035905067ffffffffffffffff81111561532757600080fd5b8060051b360382131561499057600080fd5b8183526000602080850194508260005b85811015614c7357813561535c81614867565b73ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101615349565b60208082528181018390526000906040808401600586901b8501820187855b88811015615521577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08089850301855282357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc18c360301811261540557600080fd5b8b0163ffffffff61541582614899565b168552878101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff4182360301811261544c57600080fd5b85890188905201803561545e81614867565b73ffffffffffffffffffffffffffffffffffffffff1685880152615483818901614ee3565b606060ff808316828901526154998a8501614ee3565b92506080818416818a01526154af838601614ee3565b935060a09250818416838a01526154c8818601866152d2565b60c08b810152945091506154e3905061010089018483615339565b9250506154f2818401846152d2565b93509050838783030160e088015261550b828483615339565b978a0197965050509287019250506001016153a3565b509098975050505050505050565b600082601f83011261554057600080fd5b813567ffffffffffffffff81111561555a5761555a614e19565b61558b60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601614e94565b8181528460208386010111156155a057600080fd5b816020850160208301376000918101602001919091529392505050565b600060e082360312156155cf57600080fd5b6155d7614e71565b6155e0836148ad565b81526155ee60208401614899565b60208201526155ff60408401614889565b604082015261561060608401614899565b60608201526080830135608082015260a083013560a082015260c083013567ffffffffffffffff81111561564357600080fd5b61564f3682860161552f565b60c08301525092915050565b73ffffffffffffffffffffffffffffffffffffffff831681526040602082015260006106b76040830184614b1d565b60006020828403121561569c57600080fd5b5051919050565b600060ff8216806156b6576156b6615155565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0192915050565b73ffffffffffffffffffffffffffffffffffffffff8416815263ffffffff831660208201526060604082015260006106b46060830184614c7e565b6000808585111561572957600080fd5b8386111561573657600080fd5b5050820193919092039150565b7fff0000000000000000000000000000000000000000000000000000000000000081358181169160018510156157835780818660010360031b1b83161692505b505092915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156157835760049490940360031b84901b1690921692915050565b7fffffffffffffffff00000000000000000000000000000000000000000000000081358181169160088510156157835760089490940360031b84901b1690921692915050565b80356020831015610698577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff602084900360031b1b1692915050565b60ff828116828216039081111561069857610698615155565b600060ff8316806158a6577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b8060ff84160491505092915050565b7fffff00000000000000000000000000000000000000000000000000000000000081358181169160028510156157835760029490940360031b84901b1690921692915050565b60ff818116838216019081111561069857610698615155565b73ffffffffffffffffffffffffffffffffffffffff861681526080602082015260006159436080830187614b1d565b82810360408401526159568186886151c2565b9050828103606084015261596a8185614b1d565b98975050505050505050565b60008351615988818460208801614af9565b83519083019061599c818360208801614af9565b01949350505050565b6060815260006159b86060830186614c2c565b602083820360208501526159cc8287614c2c565b84810360408601528551808252602080880194509091019060005b81811015615521578451835293830193918301916001016159e7565b60008451615a15818460208901614af9565b8201838582376000930192835250909392505050565b60007fff00000000000000000000000000000000000000000000000000000000000000808c60f81b1683527fffff000000000000000000000000000000000000000000000000000000000000808c60f01b166001850152818b60f81b1660038501527fffffffffffffffffffffffffffffffff000000000000000000000000000000008a60801b166004850152818960f81b166014850152808860f01b16601585015250808660f81b16601784015250615b0c601883018560801b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000169052565b50602881019190915260480198975050505050505050565b600060208284031215615b3657600080fd5b81516113c881614a67565b82815260008251615b59816020850160208701614af9565b919091016020019392505050565b600082516150b1818460208701614af956fea2646970667358221220a08f921b20f6954702229b9b59cb4577e9b30e40b354bc3a8c116713153fa0dd64736f6c63430008160033

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

0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b0000000000000000000000000000000000000000000000000000000000030d400000000000000000000000000000000000000000000000001bc16d674ec80000

-----Decoded View---------------
Arg [0] : _endpoint (address): 0x6F475642a6e85809B1c36Fa62763669b1b48DD5B
Arg [1] : _treasuryGasLimit (uint256): 200000
Arg [2] : _treasuryGasForFeeCap (uint256): 2000000000000000000

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b
Arg [1] : 0000000000000000000000000000000000000000000000000000000000030d40
Arg [2] : 0000000000000000000000000000000000000000000000001bc16d674ec80000


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