ETH Price: $3,785.97 (-4.85%)

Contract

0x6b8aD17795d89B283e6D0362A87A403f3544bb9d
 

Overview

ETH Balance

0.000214125129776443 ETH

Eth Value

$0.81 (@ $3,785.97/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Send Credits213670702024-12-09 19:35:2328 mins ago1733772923IN
0x6b8aD177...f3544bb9d
0.00011088 ETH0.007667427.19815679
Send Credits213670692024-12-09 19:35:1128 mins ago1733772911IN
0x6b8aD177...f3544bb9d
0.0000349 ETH0.0081780428.02138806
Send Credits213666322024-12-09 18:07:111 hr ago1733767631IN
0x6b8aD177...f3544bb9d
0.00011088 ETH0.0174009861.72554979
Send Credits213666322024-12-09 18:07:111 hr ago1733767631IN
0x6b8aD177...f3544bb9d
0.00001984 ETH0.0174009861.72554979
Send Credits213663232024-12-09 17:05:112 hrs ago1733763911IN
0x6b8aD177...f3544bb9d
0.00001658 ETH0.0109497637.60892023
Send Credits213662992024-12-09 17:00:233 hrs ago1733763623IN
0x6b8aD177...f3544bb9d
0.0001545 ETH0.0110602839.24188623
Send Credits213662732024-12-09 16:55:113 hrs ago1733763311IN
0x6b8aD177...f3544bb9d
0.0001545 ETH0.0100132935.52415425
Send Credits213660492024-12-09 16:10:233 hrs ago1733760623IN
0x6b8aD177...f3544bb9d
0.00001658 ETH0.0114155839.20565266
Send Credits213658752024-12-09 15:35:114 hrs ago1733758511IN
0x6b8aD177...f3544bb9d
0.00002024 ETH0.0107020537.96765376
Send Credits213655802024-12-09 14:35:235 hrs ago1733754923IN
0x6b8aD177...f3544bb9d
0.00006922 ETH0.0100012634.27274688
Send Credits213654552024-12-09 14:10:235 hrs ago1733753423IN
0x6b8aD177...f3544bb9d
0.00002311 ETH0.0111776839.6550521
Send Credits213651562024-12-09 13:10:236 hrs ago1733749823IN
0x6b8aD177...f3544bb9d
0.00002311 ETH0.012990446.08211296
Send Credits213651302024-12-09 13:05:116 hrs ago1733749511IN
0x6b8aD177...f3544bb9d
0.00001658 ETH0.0140394648.21908329
Send Credits213651302024-12-09 13:05:116 hrs ago1733749511IN
0x6b8aD177...f3544bb9d
0.00004209 ETH0.0140721648.21908329
Send Credits213641342024-12-09 9:45:2310 hrs ago1733737523IN
0x6b8aD177...f3544bb9d
0.00000702 ETH0.0034695412.30941177
Send Credits213641342024-12-09 9:45:2310 hrs ago1733737523IN
0x6b8aD177...f3544bb9d
0.00001906 ETH0.0034695412.30941177
Send Credits213641342024-12-09 9:45:2310 hrs ago1733737523IN
0x6b8aD177...f3544bb9d
0.00004092 ETH0.0034695412.30941177
Send Credits213641102024-12-09 9:40:3510 hrs ago1733737235IN
0x6b8aD177...f3544bb9d
0.00004092 ETH0.0037528713.31406872
Send Credits213641102024-12-09 9:40:3510 hrs ago1733737235IN
0x6b8aD177...f3544bb9d
0.00000702 ETH0.0037528713.31406872
Send Credits213641102024-12-09 9:40:3510 hrs ago1733737235IN
0x6b8aD177...f3544bb9d
0.00001906 ETH0.0037528713.31406872
Send Credits213640082024-12-09 9:20:1110 hrs ago1733736011IN
0x6b8aD177...f3544bb9d
0.00002311 ETH0.0028255510.02337439
Send Credits213639842024-12-09 9:15:2310 hrs ago1733735723IN
0x6b8aD177...f3544bb9d
0.00011088 ETH0.0029293410.39197952
Send Credits213639592024-12-09 9:10:2310 hrs ago1733735423IN
0x6b8aD177...f3544bb9d
0.00004689 ETH0.0035001411.9934666
Send Credits213639362024-12-09 9:05:4710 hrs ago1733735147IN
0x6b8aD177...f3544bb9d
0.00001906 ETH0.0035151612.46967219
Send Credits213639362024-12-09 9:05:4710 hrs ago1733735147IN
0x6b8aD177...f3544bb9d
0.00004092 ETH0.0035151612.46967219
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
213670702024-12-09 19:35:2328 mins ago1733772923
0x6b8aD177...f3544bb9d
0.00011088 ETH
213670692024-12-09 19:35:1128 mins ago1733772911
0x6b8aD177...f3544bb9d
0.0000349 ETH
213666322024-12-09 18:07:111 hr ago1733767631
0x6b8aD177...f3544bb9d
0.00011088 ETH
213666322024-12-09 18:07:111 hr ago1733767631
0x6b8aD177...f3544bb9d
0.00001984 ETH
213663232024-12-09 17:05:112 hrs ago1733763911
0x6b8aD177...f3544bb9d
0.00001658 ETH
213662992024-12-09 17:00:233 hrs ago1733763623
0x6b8aD177...f3544bb9d
0.0001545 ETH
213662732024-12-09 16:55:113 hrs ago1733763311
0x6b8aD177...f3544bb9d
0.0001545 ETH
213660492024-12-09 16:10:233 hrs ago1733760623
0x6b8aD177...f3544bb9d
0.00001658 ETH
213658752024-12-09 15:35:114 hrs ago1733758511
0x6b8aD177...f3544bb9d
0.00002024 ETH
213655802024-12-09 14:35:235 hrs ago1733754923
0x6b8aD177...f3544bb9d
0.00006922 ETH
213654552024-12-09 14:10:235 hrs ago1733753423
0x6b8aD177...f3544bb9d
0.00002311 ETH
213651562024-12-09 13:10:236 hrs ago1733749823
0x6b8aD177...f3544bb9d
0.00002311 ETH
213651302024-12-09 13:05:116 hrs ago1733749511
0x6b8aD177...f3544bb9d
0.00001658 ETH
213651302024-12-09 13:05:116 hrs ago1733749511
0x6b8aD177...f3544bb9d
0.00004209 ETH
213641342024-12-09 9:45:2310 hrs ago1733737523
0x6b8aD177...f3544bb9d
0.00000702 ETH
213641342024-12-09 9:45:2310 hrs ago1733737523
0x6b8aD177...f3544bb9d
0.00001906 ETH
213641342024-12-09 9:45:2310 hrs ago1733737523
0x6b8aD177...f3544bb9d
0.00004092 ETH
213641102024-12-09 9:40:3510 hrs ago1733737235
0x6b8aD177...f3544bb9d
0.00004092 ETH
213641102024-12-09 9:40:3510 hrs ago1733737235
0x6b8aD177...f3544bb9d
0.00000702 ETH
213641102024-12-09 9:40:3510 hrs ago1733737235
0x6b8aD177...f3544bb9d
0.00001906 ETH
213640082024-12-09 9:20:1110 hrs ago1733736011
0x6b8aD177...f3544bb9d
0.00002311 ETH
213639842024-12-09 9:15:2310 hrs ago1733735723
0x6b8aD177...f3544bb9d
0.00011088 ETH
213639592024-12-09 9:10:2310 hrs ago1733735423
0x6b8aD177...f3544bb9d
0.00004689 ETH
213639362024-12-09 9:05:4710 hrs ago1733735147
0x6b8aD177...f3544bb9d
0.00001906 ETH
213639362024-12-09 9:05:4710 hrs ago1733735147
0x6b8aD177...f3544bb9d
0.00004092 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
CreditMessaging

Compiler Version
v0.8.22+commit.4fc1097e

Optimization Enabled:
Yes with 5000 runs

Other Settings:
paris EvmVersion, BSL 1.1 license
File 1 of 39 : CreditMessaging.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;

import { MessagingFee } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol";

import { ICreditMessaging, TargetCreditBatch, TargetCredit } from "../interfaces/ICreditMessaging.sol";
import { ICreditMessagingHandler, Credit } from "../interfaces/ICreditMessagingHandler.sol";
import { CreditMsgCodec, CreditBatch } from "../libs/CreditMsgCodec.sol";
import { CreditMessagingOptions } from "./CreditMessagingOptions.sol";
import { MessagingBase, Origin } from "./MessagingBase.sol";

contract CreditMessaging is MessagingBase, CreditMessagingOptions, ICreditMessaging {
    constructor(address _endpoint, address _owner) MessagingBase(_endpoint, _owner) {}

    // ---------------------------------- Only Planner ------------------------------------------

    function sendCredits(uint32 _dstEid, TargetCreditBatch[] calldata _creditBatches) external payable onlyPlanner {
        CreditBatch[] memory batches = new CreditBatch[](_creditBatches.length);
        uint256 index = 0;
        uint128 totalCreditNum = 0; // total number of credits in all batches

        for (uint256 i = 0; i < _creditBatches.length; i++) {
            TargetCreditBatch calldata targetBatch = _creditBatches[i];
            Credit[] memory actualCredits = ICreditMessagingHandler(_safeGetStargateImpl(targetBatch.assetId))
                .sendCredits(_dstEid, targetBatch.credits);
            if (actualCredits.length > 0) {
                batches[index++] = CreditBatch(targetBatch.assetId, actualCredits);
                totalCreditNum += uint128(actualCredits.length); // safe cast
            }
        }

        if (index != 0) {
            // resize the array to the actual number of batches
            assembly {
                mstore(batches, index)
            }
            bytes memory message = CreditMsgCodec.encode(batches, totalCreditNum);
            bytes memory options = _buildOptions(_dstEid, totalCreditNum);
            _lzSend(_dstEid, message, options, MessagingFee(msg.value, 0), msg.sender);
        }
    }

    function quoteSendCredits(
        uint32 _dstEid,
        TargetCreditBatch[] calldata _creditBatches
    ) external view returns (MessagingFee memory fee) {
        CreditBatch[] memory creditBatches = new CreditBatch[](_creditBatches.length);
        uint128 creditNum = 0; // used for message encoding
        for (uint256 i = 0; i < _creditBatches.length; i++) {
            TargetCredit[] calldata targetCredits = _creditBatches[i].credits;
            Credit[] memory credits = new Credit[](targetCredits.length);
            creditNum += uint128(targetCredits.length); // safe cast
            for (uint256 j = 0; j < targetCredits.length; j++) {
                credits[j] = Credit(targetCredits[j].srcEid, targetCredits[j].amount);
            }
            creditBatches[i] = CreditBatch(_creditBatches[i].assetId, credits);
        }
        bytes memory message = CreditMsgCodec.encode(creditBatches, creditNum);
        bytes memory options = _buildOptions(_dstEid, creditNum);
        fee = _quote(_dstEid, message, options, false);
    }

    // ---------------------------------- OApp Functions ------------------------------------------

    function _lzReceive(
        Origin calldata _origin,
        bytes32 /*_guid*/,
        bytes calldata _message,
        address /*_executor*/,
        bytes calldata /*_extraData*/
    ) internal override {
        CreditBatch[] memory creditBatches = CreditMsgCodec.decode(_message);
        uint256 batchNum = creditBatches.length;
        for (uint256 i = 0; i < batchNum; i++) {
            CreditBatch memory creditBatch = creditBatches[i];
            ICreditMessagingHandler(_safeGetStargateImpl(creditBatch.assetId)).receiveCredits(
                _origin.srcEid,
                creditBatch.credits
            );
        }
    }
}

File 2 of 39 : Buffer.sol
// SPDX-License-Identifier: BSD-2-Clause
pragma solidity ^0.8.4;

/**
* @dev A library for working with mutable byte buffers in Solidity.
*
* Byte buffers are mutable and expandable, and provide a variety of primitives
* for appending to them. At any time you can fetch a bytes object containing the
* current contents of the buffer. The bytes object should not be stored between
* operations, as it may change due to resizing of the buffer.
*/
library Buffer {
    /**
    * @dev Represents a mutable buffer. Buffers have a current value (buf) and
    *      a capacity. The capacity may be longer than the current value, in
    *      which case it can be extended without the need to allocate more memory.
    */
    struct buffer {
        bytes buf;
        uint capacity;
    }

    /**
    * @dev Initializes a buffer with an initial capacity.
    * @param buf The buffer to initialize.
    * @param capacity The number of bytes of space to allocate the buffer.
    * @return The buffer, for chaining.
    */
    function init(buffer memory buf, uint capacity) internal pure returns(buffer memory) {
        if (capacity % 32 != 0) {
            capacity += 32 - (capacity % 32);
        }
        // Allocate space for the buffer data
        buf.capacity = capacity;
        assembly {
            let ptr := mload(0x40)
            mstore(buf, ptr)
            mstore(ptr, 0)
            let fpm := add(32, add(ptr, capacity))
            if lt(fpm, ptr) {
                revert(0, 0)
            }
            mstore(0x40, fpm)
        }
        return buf;
    }

    /**
    * @dev Initializes a new buffer from an existing bytes object.
    *      Changes to the buffer may mutate the original value.
    * @param b The bytes object to initialize the buffer with.
    * @return A new buffer.
    */
    function fromBytes(bytes memory b) internal pure returns(buffer memory) {
        buffer memory buf;
        buf.buf = b;
        buf.capacity = b.length;
        return buf;
    }

    function resize(buffer memory buf, uint capacity) private pure {
        bytes memory oldbuf = buf.buf;
        init(buf, capacity);
        append(buf, oldbuf);
    }

    /**
    * @dev Sets buffer length to 0.
    * @param buf The buffer to truncate.
    * @return The original buffer, for chaining..
    */
    function truncate(buffer memory buf) internal pure returns (buffer memory) {
        assembly {
            let bufptr := mload(buf)
            mstore(bufptr, 0)
        }
        return buf;
    }

    /**
    * @dev Appends len bytes of a byte string to a buffer. Resizes if doing so would exceed
    *      the capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @param len The number of bytes to copy.
    * @return The original buffer, for chaining.
    */
    function append(buffer memory buf, bytes memory data, uint len) internal pure returns(buffer memory) {
        require(len <= data.length);

        uint off = buf.buf.length;
        uint newCapacity = off + len;
        if (newCapacity > buf.capacity) {
            resize(buf, newCapacity * 2);
        }

        uint dest;
        uint src;
        assembly {
            // Memory address of the buffer data
            let bufptr := mload(buf)
            // Length of existing buffer data
            let buflen := mload(bufptr)
            // Start address = buffer address + offset + sizeof(buffer length)
            dest := add(add(bufptr, 32), off)
            // Update buffer length if we're extending it
            if gt(newCapacity, buflen) {
                mstore(bufptr, newCapacity)
            }
            src := add(data, 32)
        }

        // Copy word-length chunks while possible
        for (; len >= 32; len -= 32) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += 32;
            src += 32;
        }

        // Copy remaining bytes
        unchecked {
            uint mask = (256 ** (32 - len)) - 1;
            assembly {
                let srcpart := and(mload(src), not(mask))
                let destpart := and(mload(dest), mask)
                mstore(dest, or(destpart, srcpart))
            }
        }

        return buf;
    }

    /**
    * @dev Appends a byte string to a buffer. Resizes if doing so would exceed
    *      the capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @return The original buffer, for chaining.
    */
    function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {
        return append(buf, data, data.length);
    }

    /**
    * @dev Appends a byte to the buffer. Resizes if doing so would exceed the
    *      capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @return The original buffer, for chaining.
    */
    function appendUint8(buffer memory buf, uint8 data) internal pure returns(buffer memory) {
        uint off = buf.buf.length;
        uint offPlusOne = off + 1;
        if (off >= buf.capacity) {
            resize(buf, offPlusOne * 2);
        }

        assembly {
            // Memory address of the buffer data
            let bufptr := mload(buf)
            // Address = buffer address + sizeof(buffer length) + off
            let dest := add(add(bufptr, off), 32)
            mstore8(dest, data)
            // Update buffer length if we extended it
            if gt(offPlusOne, mload(bufptr)) {
                mstore(bufptr, offPlusOne)
            }
        }

        return buf;
    }

    /**
    * @dev Appends len bytes of bytes32 to a buffer. Resizes if doing so would
    *      exceed the capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @param len The number of bytes to write (left-aligned).
    * @return The original buffer, for chaining.
    */
    function append(buffer memory buf, bytes32 data, uint len) private pure returns(buffer memory) {
        uint off = buf.buf.length;
        uint newCapacity = len + off;
        if (newCapacity > buf.capacity) {
            resize(buf, newCapacity * 2);
        }

        unchecked {
            uint mask = (256 ** len) - 1;
            // Right-align data
            data = data >> (8 * (32 - len));
            assembly {
                // Memory address of the buffer data
                let bufptr := mload(buf)
                // Address = buffer address + sizeof(buffer length) + newCapacity
                let dest := add(bufptr, newCapacity)
                mstore(dest, or(and(mload(dest), not(mask)), data))
                // Update buffer length if we extended it
                if gt(newCapacity, mload(bufptr)) {
                    mstore(bufptr, newCapacity)
                }
            }
        }
        return buf;
    }

    /**
    * @dev Appends a bytes20 to the buffer. Resizes if doing so would exceed
    *      the capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @return The original buffer, for chhaining.
    */
    function appendBytes20(buffer memory buf, bytes20 data) internal pure returns (buffer memory) {
        return append(buf, bytes32(data), 20);
    }

    /**
    * @dev Appends a bytes32 to the buffer. Resizes if doing so would exceed
    *      the capacity of the buffer.
    * @param buf The buffer to append to.
    * @param data The data to append.
    * @return The original buffer, for chaining.
    */
    function appendBytes32(buffer memory buf, bytes32 data) internal pure returns (buffer memory) {
        return append(buf, data, 32);
    }

    /**
     * @dev Appends a byte to the end of the buffer. Resizes if doing so would
     *      exceed the capacity of the buffer.
     * @param buf The buffer to append to.
     * @param data The data to append.
     * @param len The number of bytes to write (right-aligned).
     * @return The original buffer.
     */
    function appendInt(buffer memory buf, uint data, uint len) internal pure returns(buffer memory) {
        uint off = buf.buf.length;
        uint newCapacity = len + off;
        if (newCapacity > buf.capacity) {
            resize(buf, newCapacity * 2);
        }

        uint mask = (256 ** len) - 1;
        assembly {
            // Memory address of the buffer data
            let bufptr := mload(buf)
            // Address = buffer address + sizeof(buffer length) + newCapacity
            let dest := add(bufptr, newCapacity)
            mstore(dest, or(and(mload(dest), not(mask)), data))
            // Update buffer length if we extended it
            if gt(newCapacity, mload(bufptr)) {
                mstore(bufptr, newCapacity)
            }
        }
        return buf;
    }
}

File 3 of 39 : OApp.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

// @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers
// solhint-disable-next-line no-unused-import
import { OAppSender, MessagingFee, MessagingReceipt } from "./OAppSender.sol";
// @dev Import the 'Origin' so it's exposed to OApp implementers
// solhint-disable-next-line no-unused-import
import { OAppReceiver, Origin } from "./OAppReceiver.sol";
import { OAppCore } from "./OAppCore.sol";

/**
 * @title OApp
 * @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.
 */
abstract contract OApp is OAppSender, OAppReceiver {
    /**
     * @dev Constructor to initialize the OApp with the provided endpoint and owner.
     * @param _endpoint The address of the LOCAL LayerZero endpoint.
     * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
     */
    constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {}

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol implementation.
     * @return receiverVersion The version of the OAppReceiver.sol implementation.
     */
    function oAppVersion()
        public
        pure
        virtual
        override(OAppSender, OAppReceiver)
        returns (uint64 senderVersion, uint64 receiverVersion)
    {
        return (SENDER_VERSION, RECEIVER_VERSION);
    }
}

File 4 of 39 : OAppCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol";

/**
 * @title OAppCore
 * @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.
 */
abstract contract OAppCore is IOAppCore, Ownable {
    // The LayerZero endpoint associated with the given OApp
    ILayerZeroEndpointV2 public immutable endpoint;

    // Mapping to store peers associated with corresponding endpoints
    mapping(uint32 eid => bytes32 peer) public peers;

    /**
     * @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.
     * @param _endpoint The address of the LOCAL Layer Zero endpoint.
     * @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
     *
     * @dev The delegate typically should be set as the owner of the contract.
     */
    constructor(address _endpoint, address _delegate) {
        endpoint = ILayerZeroEndpointV2(_endpoint);

        if (_delegate == address(0)) revert InvalidDelegate();
        endpoint.setDelegate(_delegate);
    }

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     *
     * @dev Only the owner/admin of the OApp can call this function.
     * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
     * @dev Set this to bytes32(0) to remove the peer address.
     * @dev Peer is a bytes32 to accommodate non-evm chains.
     */
    function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {
        _setPeer(_eid, _peer);
    }

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     *
     * @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
     * @dev Set this to bytes32(0) to remove the peer address.
     * @dev Peer is a bytes32 to accommodate non-evm chains.
     */
    function _setPeer(uint32 _eid, bytes32 _peer) internal virtual {
        peers[_eid] = _peer;
        emit PeerSet(_eid, _peer);
    }

    /**
     * @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.
     * ie. the peer is set to bytes32(0).
     * @param _eid The endpoint ID.
     * @return peer The address of the peer associated with the specified endpoint.
     */
    function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {
        bytes32 peer = peers[_eid];
        if (peer == bytes32(0)) revert NoPeer(_eid);
        return peer;
    }

    /**
     * @notice Sets the delegate address for the OApp.
     * @param _delegate The address of the delegate to be set.
     *
     * @dev Only the owner/admin of the OApp can call this function.
     * @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.
     */
    function setDelegate(address _delegate) public onlyOwner {
        endpoint.setDelegate(_delegate);
    }
}

File 5 of 39 : OAppReceiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { IOAppReceiver, Origin } from "./interfaces/IOAppReceiver.sol";
import { OAppCore } from "./OAppCore.sol";

/**
 * @title OAppReceiver
 * @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.
 */
abstract contract OAppReceiver is IOAppReceiver, OAppCore {
    // Custom error message for when the caller is not the registered endpoint/
    error OnlyEndpoint(address addr);

    // @dev The version of the OAppReceiver implementation.
    // @dev Version is bumped when changes are made to this contract.
    uint64 internal constant RECEIVER_VERSION = 2;

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol contract.
     * @return receiverVersion The version of the OAppReceiver.sol contract.
     *
     * @dev Providing 0 as the default for OAppSender version. Indicates that the OAppSender is not implemented.
     * ie. this is a RECEIVE only OApp.
     * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions.
     */
    function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {
        return (0, RECEIVER_VERSION);
    }

    /**
     * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.
     * @dev _origin The origin information containing the source endpoint and sender address.
     *  - srcEid: The source chain endpoint ID.
     *  - sender: The sender address on the src chain.
     *  - nonce: The nonce of the message.
     * @dev _message The lzReceive payload.
     * @param _sender The sender address.
     * @return isSender Is a valid sender.
     *
     * @dev Applications can optionally choose to implement separate composeMsg senders that are NOT the bridging layer.
     * @dev The default sender IS the OAppReceiver implementer.
     */
    function isComposeMsgSender(
        Origin calldata /*_origin*/,
        bytes calldata /*_message*/,
        address _sender
    ) public view virtual returns (bool) {
        return _sender == address(this);
    }

    /**
     * @notice Checks if the path initialization is allowed based on the provided origin.
     * @param origin The origin information containing the source endpoint and sender address.
     * @return Whether the path has been initialized.
     *
     * @dev This indicates to the endpoint that the OApp has enabled msgs for this particular path to be received.
     * @dev This defaults to assuming if a peer has been set, its initialized.
     * Can be overridden by the OApp if there is other logic to determine this.
     */
    function allowInitializePath(Origin calldata origin) public view virtual returns (bool) {
        return peers[origin.srcEid] == origin.sender;
    }

    /**
     * @notice Retrieves the next nonce for a given source endpoint and sender address.
     * @dev _srcEid The source endpoint ID.
     * @dev _sender The sender address.
     * @return nonce The next nonce.
     *
     * @dev The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement.
     * @dev Is required by the off-chain executor to determine the OApp expects msg execution is ordered.
     * @dev This is also enforced by the OApp.
     * @dev By default this is NOT enabled. ie. nextNonce is hardcoded to return 0.
     */
    function nextNonce(uint32 /*_srcEid*/, bytes32 /*_sender*/) public view virtual returns (uint64 nonce) {
        return 0;
    }

    /**
     * @dev Entry point for receiving messages or packets from the endpoint.
     * @param _origin The origin information containing the source endpoint and sender address.
     *  - srcEid: The source chain endpoint ID.
     *  - sender: The sender address on the src chain.
     *  - nonce: The nonce of the message.
     * @param _guid The unique identifier for the received LayerZero message.
     * @param _message The payload of the received message.
     * @param _executor The address of the executor for the received message.
     * @param _extraData Additional arbitrary data provided by the corresponding executor.
     *
     * @dev Entry point for receiving msg/packet from the LayerZero endpoint.
     */
    function lzReceive(
        Origin calldata _origin,
        bytes32 _guid,
        bytes calldata _message,
        address _executor,
        bytes calldata _extraData
    ) public payable virtual {
        // Ensures that only the endpoint can attempt to lzReceive() messages to this OApp.
        if (address(endpoint) != msg.sender) revert OnlyEndpoint(msg.sender);

        // Ensure that the sender matches the expected peer for the source endpoint.
        if (_getPeerOrRevert(_origin.srcEid) != _origin.sender) revert OnlyPeer(_origin.srcEid, _origin.sender);

        // Call the internal OApp implementation of lzReceive.
        _lzReceive(_origin, _guid, _message, _executor, _extraData);
    }

    /**
     * @dev Internal function to implement lzReceive logic without needing to copy the basic parameter validation.
     */
    function _lzReceive(
        Origin calldata _origin,
        bytes32 _guid,
        bytes calldata _message,
        address _executor,
        bytes calldata _extraData
    ) internal virtual;
}

File 6 of 39 : OAppSender.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { SafeERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { OAppCore } from "./OAppCore.sol";

/**
 * @title OAppSender
 * @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.
 */
abstract contract OAppSender is OAppCore {
    using SafeERC20 for IERC20;

    // Custom error messages
    error NotEnoughNative(uint256 msgValue);
    error LzTokenUnavailable();

    // @dev The version of the OAppSender implementation.
    // @dev Version is bumped when changes are made to this contract.
    uint64 internal constant SENDER_VERSION = 1;

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol contract.
     * @return receiverVersion The version of the OAppReceiver.sol contract.
     *
     * @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.
     * ie. this is a SEND only OApp.
     * @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions
     */
    function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {
        return (SENDER_VERSION, 0);
    }

    /**
     * @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.
     * @param _dstEid The destination endpoint ID.
     * @param _message The message payload.
     * @param _options Additional options for the message.
     * @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.
     * @return fee The calculated MessagingFee for the message.
     *      - nativeFee: The native fee for the message.
     *      - lzTokenFee: The LZ token fee for the message.
     */
    function _quote(
        uint32 _dstEid,
        bytes memory _message,
        bytes memory _options,
        bool _payInLzToken
    ) internal view virtual returns (MessagingFee memory fee) {
        return
            endpoint.quote(
                MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),
                address(this)
            );
    }

    /**
     * @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.
     * @param _dstEid The destination endpoint ID.
     * @param _message The message payload.
     * @param _options Additional options for the message.
     * @param _fee The calculated LayerZero fee for the message.
     *      - nativeFee: The native fee.
     *      - lzTokenFee: The lzToken fee.
     * @param _refundAddress The address to receive any excess fee values sent to the endpoint.
     * @return receipt The receipt for the sent message.
     *      - guid: The unique identifier for the sent message.
     *      - nonce: The nonce of the sent message.
     *      - fee: The LayerZero fee incurred for the message.
     */
    function _lzSend(
        uint32 _dstEid,
        bytes memory _message,
        bytes memory _options,
        MessagingFee memory _fee,
        address _refundAddress
    ) internal virtual returns (MessagingReceipt memory receipt) {
        // @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.
        uint256 messageValue = _payNative(_fee.nativeFee);
        if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);

        return
            // solhint-disable-next-line check-send-result
            endpoint.send{ value: messageValue }(
                MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),
                _refundAddress
            );
    }

    /**
     * @dev Internal function to pay the native fee associated with the message.
     * @param _nativeFee The native fee to be paid.
     * @return nativeFee The amount of native currency paid.
     *
     * @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,
     * this will need to be overridden because msg.value would contain multiple lzFees.
     * @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.
     * @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.
     * @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.
     */
    function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {
        if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);
        return _nativeFee;
    }

    /**
     * @dev Internal function to pay the LZ token fee associated with the message.
     * @param _lzTokenFee The LZ token fee to be paid.
     *
     * @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.
     * @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().
     */
    function _payLzToken(uint256 _lzTokenFee) internal virtual {
        // @dev Cannot cache the token because it is not immutable in the endpoint.
        address lzToken = endpoint.lzToken();
        if (lzToken == address(0)) revert LzTokenUnavailable();

        // Pay LZ token fee by sending tokens to the endpoint.
        IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);
    }
}

File 7 of 39 : IOAppCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";

/**
 * @title IOAppCore
 */
interface IOAppCore {
    // Custom error messages
    error OnlyPeer(uint32 eid, bytes32 sender);
    error NoPeer(uint32 eid);
    error InvalidEndpointCall();
    error InvalidDelegate();

    // Event emitted when a peer (OApp) is set for a corresponding endpoint
    event PeerSet(uint32 eid, bytes32 peer);

    /**
     * @notice Retrieves the OApp version information.
     * @return senderVersion The version of the OAppSender.sol contract.
     * @return receiverVersion The version of the OAppReceiver.sol contract.
     */
    function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);

    /**
     * @notice Retrieves the LayerZero endpoint associated with the OApp.
     * @return iEndpoint The LayerZero endpoint as an interface.
     */
    function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);

    /**
     * @notice Retrieves the peer (OApp) associated with a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @return peer The peer address (OApp instance) associated with the corresponding endpoint.
     */
    function peers(uint32 _eid) external view returns (bytes32 peer);

    /**
     * @notice Sets the peer address (OApp instance) for a corresponding endpoint.
     * @param _eid The endpoint ID.
     * @param _peer The address of the peer to be associated with the corresponding endpoint.
     */
    function setPeer(uint32 _eid, bytes32 _peer) external;

    /**
     * @notice Sets the delegate address for the OApp Core.
     * @param _delegate The address of the delegate to be set.
     */
    function setDelegate(address _delegate) external;
}

File 8 of 39 : IOAppOptionsType3.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

/**
 * @dev Struct representing enforced option parameters.
 */
struct EnforcedOptionParam {
    uint32 eid; // Endpoint ID
    uint16 msgType; // Message Type
    bytes options; // Additional options
}

/**
 * @title IOAppOptionsType3
 * @dev Interface for the OApp with Type 3 Options, allowing the setting and combining of enforced options.
 */
interface IOAppOptionsType3 {
    // Custom error message for invalid options
    error InvalidOptions(bytes options);

    // Event emitted when enforced options are set
    event EnforcedOptionSet(EnforcedOptionParam[] _enforcedOptions);

    /**
     * @notice Sets enforced options for specific endpoint and message type combinations.
     * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options.
     */
    function setEnforcedOptions(EnforcedOptionParam[] calldata _enforcedOptions) external;

    /**
     * @notice Combines options for a given endpoint and message type.
     * @param _eid The endpoint ID.
     * @param _msgType The OApp message type.
     * @param _extraOptions Additional options passed by the caller.
     * @return options The combination of caller specified options AND enforced options.
     */
    function combineOptions(
        uint32 _eid,
        uint16 _msgType,
        bytes calldata _extraOptions
    ) external view returns (bytes memory options);
}

File 9 of 39 : IOAppReceiver.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { ILayerZeroReceiver, Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroReceiver.sol";

interface IOAppReceiver is ILayerZeroReceiver {
    /**
     * @notice Indicates whether an address is an approved composeMsg sender to the Endpoint.
     * @param _origin The origin information containing the source endpoint and sender address.
     *  - srcEid: The source chain endpoint ID.
     *  - sender: The sender address on the src chain.
     *  - nonce: The nonce of the message.
     * @param _message The lzReceive payload.
     * @param _sender The sender address.
     * @return isSender Is a valid sender.
     *
     * @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer.
     * @dev The default sender IS the OAppReceiver implementer.
     */
    function isComposeMsgSender(
        Origin calldata _origin,
        bytes calldata _message,
        address _sender
    ) external view returns (bool isSender);
}

File 10 of 39 : OAppOptionsType3.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IOAppOptionsType3, EnforcedOptionParam } from "../interfaces/IOAppOptionsType3.sol";

/**
 * @title OAppOptionsType3
 * @dev Abstract contract implementing the IOAppOptionsType3 interface with type 3 options.
 */
abstract contract OAppOptionsType3 is IOAppOptionsType3, Ownable {
    uint16 internal constant OPTION_TYPE_3 = 3;

    // @dev The "msgType" should be defined in the child contract.
    mapping(uint32 eid => mapping(uint16 msgType => bytes enforcedOption)) public enforcedOptions;

    /**
     * @dev Sets the enforced options for specific endpoint and message type combinations.
     * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options.
     *
     * @dev Only the owner/admin of the OApp can call this function.
     * @dev Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc.
     * @dev These enforced options can vary as the potential options/execution on the remote may differ as per the msgType.
     * eg. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you dont want to pay
     * if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose().
     */
    function setEnforcedOptions(EnforcedOptionParam[] calldata _enforcedOptions) public virtual onlyOwner {
        _setEnforcedOptions(_enforcedOptions);
    }

    /**
     * @dev Sets the enforced options for specific endpoint and message type combinations.
     * @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options.
     *
     * @dev Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc.
     * @dev These enforced options can vary as the potential options/execution on the remote may differ as per the msgType.
     * eg. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you dont want to pay
     * if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose().
     */
    function _setEnforcedOptions(EnforcedOptionParam[] memory _enforcedOptions) internal virtual {
        for (uint256 i = 0; i < _enforcedOptions.length; i++) {
            // @dev Enforced options are only available for optionType 3, as type 1 and 2 dont support combining.
            _assertOptionsType3(_enforcedOptions[i].options);
            enforcedOptions[_enforcedOptions[i].eid][_enforcedOptions[i].msgType] = _enforcedOptions[i].options;
        }

        emit EnforcedOptionSet(_enforcedOptions);
    }

    /**
     * @notice Combines options for a given endpoint and message type.
     * @param _eid The endpoint ID.
     * @param _msgType The OAPP message type.
     * @param _extraOptions Additional options passed by the caller.
     * @return options The combination of caller specified options AND enforced options.
     *
     * @dev If there is an enforced lzReceive option:
     * - {gasLimit: 200k, msg.value: 1 ether} AND a caller supplies a lzReceive option: {gasLimit: 100k, msg.value: 0.5 ether}
     * - The resulting options will be {gasLimit: 300k, msg.value: 1.5 ether} when the message is executed on the remote lzReceive() function.
     * @dev This presence of duplicated options is handled off-chain in the verifier/executor.
     */
    function combineOptions(
        uint32 _eid,
        uint16 _msgType,
        bytes calldata _extraOptions
    ) public view virtual returns (bytes memory) {
        bytes memory enforced = enforcedOptions[_eid][_msgType];

        // No enforced options, pass whatever the caller supplied, even if it's empty or legacy type 1/2 options.
        if (enforced.length == 0) return _extraOptions;

        // No caller options, return enforced
        if (_extraOptions.length == 0) return enforced;

        // @dev If caller provided _extraOptions, must be type 3 as its the ONLY type that can be combined.
        if (_extraOptions.length >= 2) {
            _assertOptionsType3(_extraOptions);
            // @dev Remove the first 2 bytes containing the type from the _extraOptions and combine with enforced.
            return bytes.concat(enforced, _extraOptions[2:]);
        }

        // No valid set of options was found.
        revert InvalidOptions(_extraOptions);
    }

    /**
     * @dev Internal function to assert that options are of type 3.
     * @param _options The options to be checked.
     */
    function _assertOptionsType3(bytes memory _options) internal pure virtual {
        uint16 optionsType;
        assembly {
            optionsType := mload(add(_options, 2))
        }
        if (optionsType != OPTION_TYPE_3) revert InvalidOptions(_options);
    }
}

File 11 of 39 : IOFT.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol";

/**
 * @dev Struct representing token parameters for the OFT send() operation.
 */
struct SendParam {
    uint32 dstEid; // Destination endpoint ID.
    bytes32 to; // Recipient address.
    uint256 amountLD; // Amount to send in local decimals.
    uint256 minAmountLD; // Minimum amount to send in local decimals.
    bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
    bytes composeMsg; // The composed message for the send() operation.
    bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}

/**
 * @dev Struct representing OFT limit information.
 * @dev These amounts can change dynamically and are up the the specific oft implementation.
 */
struct OFTLimit {
    uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
    uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}

/**
 * @dev Struct representing OFT receipt information.
 */
struct OFTReceipt {
    uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
    // @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
    uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}

/**
 * @dev Struct representing OFT fee details.
 * @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
 */
struct OFTFeeDetail {
    int256 feeAmountLD; // Amount of the fee in local decimals.
    string description; // Description of the fee.
}

/**
 * @title IOFT
 * @dev Interface for the OftChain (OFT) token.
 * @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
 * @dev This specific interface ID is '0x02e49c2c'.
 */
interface IOFT {
    // Custom error messages
    error InvalidLocalDecimals();
    error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);

    // Events
    event OFTSent(
        bytes32 indexed guid, // GUID of the OFT message.
        uint32 dstEid, // Destination Endpoint ID.
        address indexed fromAddress, // Address of the sender on the src chain.
        uint256 amountSentLD, // Amount of tokens sent in local decimals.
        uint256 amountReceivedLD // Amount of tokens received in local decimals.
    );
    event OFTReceived(
        bytes32 indexed guid, // GUID of the OFT message.
        uint32 srcEid, // Source Endpoint ID.
        address indexed toAddress, // Address of the recipient on the dst chain.
        uint256 amountReceivedLD // Amount of tokens received in local decimals.
    );

    /**
     * @notice Retrieves interfaceID and the version of the OFT.
     * @return interfaceId The interface ID.
     * @return version The version.
     *
     * @dev interfaceId: This specific interface ID is '0x02e49c2c'.
     * @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
     * @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
     * ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
     */
    function oftVersion() external view returns (bytes4 interfaceId, uint64 version);

    /**
     * @notice Retrieves the address of the token associated with the OFT.
     * @return token The address of the ERC20 token implementation.
     */
    function token() external view returns (address);

    /**
     * @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
     * @return requiresApproval Needs approval of the underlying token implementation.
     *
     * @dev Allows things like wallet implementers to determine integration requirements,
     * without understanding the underlying token implementation.
     */
    function approvalRequired() external view returns (bool);

    /**
     * @notice Retrieves the shared decimals of the OFT.
     * @return sharedDecimals The shared decimals of the OFT.
     */
    function sharedDecimals() external view returns (uint8);

    /**
     * @notice Provides a quote for OFT-related operations.
     * @param _sendParam The parameters for the send operation.
     * @return limit The OFT limit information.
     * @return oftFeeDetails The details of OFT fees.
     * @return receipt The OFT receipt information.
     */
    function quoteOFT(
        SendParam calldata _sendParam
    ) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory);

    /**
     * @notice Provides a quote for the send() operation.
     * @param _sendParam The parameters for the send() operation.
     * @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
     * @return fee The calculated LayerZero messaging fee from the send() operation.
     *
     * @dev MessagingFee: LayerZero msg fee
     *  - nativeFee: The native fee.
     *  - lzTokenFee: The lzToken fee.
     */
    function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory);

    /**
     * @notice Executes the send() operation.
     * @param _sendParam The parameters for the send operation.
     * @param _fee The fee information supplied by the caller.
     *      - nativeFee: The native fee.
     *      - lzTokenFee: The lzToken fee.
     * @param _refundAddress The address to receive any excess funds from fees etc. on the src.
     * @return receipt The LayerZero messaging receipt from the send() operation.
     * @return oftReceipt The OFT receipt information.
     *
     * @dev MessagingReceipt: LayerZero msg receipt
     *  - guid: The unique identifier for the sent message.
     *  - nonce: The nonce of the sent message.
     *  - fee: The LayerZero fee incurred for the message.
     */
    function send(
        SendParam calldata _sendParam,
        MessagingFee calldata _fee,
        address _refundAddress
    ) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}

File 12 of 39 : OAppPreCrimeSimulator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IPreCrime } from "./interfaces/IPreCrime.sol";
import { IOAppPreCrimeSimulator, InboundPacket, Origin } from "./interfaces/IOAppPreCrimeSimulator.sol";

/**
 * @title OAppPreCrimeSimulator
 * @dev Abstract contract serving as the base for preCrime simulation functionality in an OApp.
 */
abstract contract OAppPreCrimeSimulator is IOAppPreCrimeSimulator, Ownable {
    // The address of the preCrime implementation.
    address public preCrime;

    /**
     * @dev Retrieves the address of the OApp contract.
     * @return The address of the OApp contract.
     *
     * @dev The simulator contract is the base contract for the OApp by default.
     * @dev If the simulator is a separate contract, override this function.
     */
    function oApp() external view virtual returns (address) {
        return address(this);
    }

    /**
     * @dev Sets the preCrime contract address.
     * @param _preCrime The address of the preCrime contract.
     */
    function setPreCrime(address _preCrime) public virtual onlyOwner {
        preCrime = _preCrime;
        emit PreCrimeSet(_preCrime);
    }

    /**
     * @dev Interface for pre-crime simulations. Always reverts at the end with the simulation results.
     * @param _packets An array of InboundPacket objects representing received packets to be delivered.
     *
     * @dev WARNING: MUST revert at the end with the simulation results.
     * @dev Gives the preCrime implementation the ability to mock sending packets to the lzReceive function,
     * WITHOUT actually executing them.
     */
    function lzReceiveAndRevert(InboundPacket[] calldata _packets) public payable virtual {
        for (uint256 i = 0; i < _packets.length; i++) {
            InboundPacket calldata packet = _packets[i];

            // Ignore packets that are not from trusted peers.
            if (!isPeer(packet.origin.srcEid, packet.origin.sender)) continue;

            // @dev Because a verifier is calling this function, it doesnt have access to executor params:
            //  - address _executor
            //  - bytes calldata _extraData
            // preCrime will NOT work for OApps that rely on these two parameters inside of their _lzReceive().
            // They are instead stubbed to default values, address(0) and bytes("")
            // @dev Calling this.lzReceiveSimulate removes ability for assembly return 0 callstack exit,
            // which would cause the revert to be ignored.
            this.lzReceiveSimulate{ value: packet.value }(
                packet.origin,
                packet.guid,
                packet.message,
                packet.executor,
                packet.extraData
            );
        }

        // @dev Revert with the simulation results. msg.sender must implement IPreCrime.buildSimulationResult().
        revert SimulationResult(IPreCrime(msg.sender).buildSimulationResult());
    }

    /**
     * @dev Is effectively an internal function because msg.sender must be address(this).
     * Allows resetting the call stack for 'internal' calls.
     * @param _origin The origin information containing the source endpoint and sender address.
     *  - srcEid: The source chain endpoint ID.
     *  - sender: The sender address on the src chain.
     *  - nonce: The nonce of the message.
     * @param _guid The unique identifier of the packet.
     * @param _message The message payload of the packet.
     * @param _executor The executor address for the packet.
     * @param _extraData Additional data for the packet.
     */
    function lzReceiveSimulate(
        Origin calldata _origin,
        bytes32 _guid,
        bytes calldata _message,
        address _executor,
        bytes calldata _extraData
    ) external payable virtual {
        // @dev Ensure ONLY can be called 'internally'.
        if (msg.sender != address(this)) revert OnlySelf();
        _lzReceiveSimulate(_origin, _guid, _message, _executor, _extraData);
    }

    /**
     * @dev Internal function to handle the OAppPreCrimeSimulator simulated receive.
     * @param _origin The origin information.
     *  - srcEid: The source chain endpoint ID.
     *  - sender: The sender address from the src chain.
     *  - nonce: The nonce of the LayerZero message.
     * @param _guid The GUID of the LayerZero message.
     * @param _message The LayerZero message.
     * @param _executor The address of the off-chain executor.
     * @param _extraData Arbitrary data passed by the msg executor.
     *
     * @dev Enables the preCrime simulator to mock sending lzReceive() messages,
     * routes the msg down from the OAppPreCrimeSimulator, and back up to the OAppReceiver.
     */
    function _lzReceiveSimulate(
        Origin calldata _origin,
        bytes32 _guid,
        bytes calldata _message,
        address _executor,
        bytes calldata _extraData
    ) internal virtual;

    /**
     * @dev checks if the specified peer is considered 'trusted' by the OApp.
     * @param _eid The endpoint Id to check.
     * @param _peer The peer to check.
     * @return Whether the peer passed is considered 'trusted' by the OApp.
     */
    function isPeer(uint32 _eid, bytes32 _peer) public view virtual returns (bool);
}

File 13 of 39 : IOAppPreCrimeSimulator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

// @dev Import the Origin so it's exposed to OAppPreCrimeSimulator implementers.
// solhint-disable-next-line no-unused-import
import { InboundPacket, Origin } from "../libs/Packet.sol";

/**
 * @title IOAppPreCrimeSimulator Interface
 * @dev Interface for the preCrime simulation functionality in an OApp.
 */
interface IOAppPreCrimeSimulator {
    // @dev simulation result used in PreCrime implementation
    error SimulationResult(bytes result);
    error OnlySelf();

    /**
     * @dev Emitted when the preCrime contract address is set.
     * @param preCrimeAddress The address of the preCrime contract.
     */
    event PreCrimeSet(address preCrimeAddress);

    /**
     * @dev Retrieves the address of the preCrime contract implementation.
     * @return The address of the preCrime contract.
     */
    function preCrime() external view returns (address);

    /**
     * @dev Retrieves the address of the OApp contract.
     * @return The address of the OApp contract.
     */
    function oApp() external view returns (address);

    /**
     * @dev Sets the preCrime contract address.
     * @param _preCrime The address of the preCrime contract.
     */
    function setPreCrime(address _preCrime) external;

    /**
     * @dev Mocks receiving a packet, then reverts with a series of data to infer the state/result.
     * @param _packets An array of LayerZero InboundPacket objects representing received packets.
     */
    function lzReceiveAndRevert(InboundPacket[] calldata _packets) external payable;

    /**
     * @dev checks if the specified peer is considered 'trusted' by the OApp.
     * @param _eid The endpoint Id to check.
     * @param _peer The peer to check.
     * @return Whether the peer passed is considered 'trusted' by the OApp.
     */
    function isPeer(uint32 _eid, bytes32 _peer) external view returns (bool);
}

File 14 of 39 : IPreCrime.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;
struct PreCrimePeer {
    uint32 eid;
    bytes32 preCrime;
    bytes32 oApp;
}

// TODO not done yet
interface IPreCrime {
    error OnlyOffChain();

    // for simulate()
    error PacketOversize(uint256 max, uint256 actual);
    error PacketUnsorted();
    error SimulationFailed(bytes reason);

    // for preCrime()
    error SimulationResultNotFound(uint32 eid);
    error InvalidSimulationResult(uint32 eid, bytes reason);
    error CrimeFound(bytes crime);

    function getConfig(bytes[] calldata _packets, uint256[] calldata _packetMsgValues) external returns (bytes memory);

    function simulate(
        bytes[] calldata _packets,
        uint256[] calldata _packetMsgValues
    ) external payable returns (bytes memory);

    function buildSimulationResult() external view returns (bytes memory);

    function preCrime(
        bytes[] calldata _packets,
        uint256[] calldata _packetMsgValues,
        bytes[] calldata _simulations
    ) external;

    function version() external view returns (uint64 major, uint8 minor);
}

File 15 of 39 : Packet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import { Origin } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { PacketV1Codec } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/PacketV1Codec.sol";

/**
 * @title InboundPacket
 * @dev Structure representing an inbound packet received by the contract.
 */
struct InboundPacket {
    Origin origin; // Origin information of the packet.
    uint32 dstEid; // Destination endpointId of the packet.
    address receiver; // Receiver address for the packet.
    bytes32 guid; // Unique identifier of the packet.
    uint256 value; // msg.value of the packet.
    address executor; // Executor address for the packet.
    bytes message; // Message payload of the packet.
    bytes extraData; // Additional arbitrary data for the packet.
}

/**
 * @title PacketDecoder
 * @dev Library for decoding LayerZero packets.
 */
library PacketDecoder {
    using PacketV1Codec for bytes;

    /**
     * @dev Decode an inbound packet from the given packet data.
     * @param _packet The packet data to decode.
     * @return packet An InboundPacket struct representing the decoded packet.
     */
    function decode(bytes calldata _packet) internal pure returns (InboundPacket memory packet) {
        packet.origin = Origin(_packet.srcEid(), _packet.sender(), _packet.nonce());
        packet.dstEid = _packet.dstEid();
        packet.receiver = _packet.receiverB20();
        packet.guid = _packet.guid();
        packet.message = _packet.message();
    }

    /**
     * @dev Decode multiple inbound packets from the given packet data and associated message values.
     * @param _packets An array of packet data to decode.
     * @param _packetMsgValues An array of associated message values for each packet.
     * @return packets An array of InboundPacket structs representing the decoded packets.
     */
    function decode(
        bytes[] calldata _packets,
        uint256[] memory _packetMsgValues
    ) internal pure returns (InboundPacket[] memory packets) {
        packets = new InboundPacket[](_packets.length);
        for (uint256 i = 0; i < _packets.length; i++) {
            bytes calldata packet = _packets[i];
            packets[i] = PacketDecoder.decode(packet);
            // @dev Allows the verifier to specify the msg.value that gets passed in lzReceive.
            packets[i].value = _packetMsgValues[i];
        }
    }
}

File 16 of 39 : 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;
}

enum ExecutionState {
    NotExecutable,
    Executable,
    Executed
}

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);

    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,
        address _receiveLib,
        bytes32 _payloadHash
    ) external view returns (bool);

    function executable(Origin calldata _origin, address _receiver) external view returns (ExecutionState);

    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 17 of 39 : ILayerZeroReceiver.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

import { Origin } from "./ILayerZeroEndpointV2.sol";

interface ILayerZeroReceiver {
    function allowInitializePath(Origin calldata _origin) external view returns (bool);

    // todo: move to OAppReceiver? it is just convention for executor. we may can change it in a new Receiver version
    function nextNonce(uint32 _eid, bytes32 _sender) external view returns (uint64);

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

File 18 of 39 : 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 19 of 39 : 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 oldLib, 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 oldLib, 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 _timeout) 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);

    /// ------------------- 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 _gracePeriod) 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 20 of 39 : 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);
}

File 21 of 39 : 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 22 of 39 : 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 23 of 39 : 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 24 of 39 : AddressCast.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.22;

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

library AddressCast {
    function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) {
        if (_addressBytes.length > 32) revert Errors.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 Errors.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 Errors.InvalidAddress();
        result = address(bytes20(_addressBytes));
    }
}

File 25 of 39 : Errors.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.22;

library Errors {
    error LzTokenUnavailable();
    error OnlyAltToken();
    error InvalidReceiveLibrary();
    error InvalidNonce(uint64 nonce);
    error InvalidArgument();
    error InvalidExpiry();
    error InvalidAmount(uint256 required, uint256 supplied);
    error OnlyRegisteredOrDefaultLib();
    error OnlyRegisteredLib();
    error OnlyNonDefaultLib();
    error Unauthorized();
    error DefaultSendLibUnavailable();
    error DefaultReceiveLibUnavailable();
    error PathNotInitializable();
    error PathNotVerifiable();
    error OnlySendLib();
    error OnlyReceiveLib();
    error UnsupportedEid();
    error UnsupportedInterface();
    error AlreadyRegistered();
    error SameValue();
    error InvalidPayloadHash();
    error PayloadHashNotFound(bytes32 expected, bytes32 actual);
    error ComposeNotFound(bytes32 expected, bytes32 actual);
    error ComposeExists();
    error SendReentrancy();
    error NotImplemented();
    error InvalidAddress();
    error InvalidSizeForAddress();
    error InsufficientFee(
        uint256 requiredNative,
        uint256 suppliedNative,
        uint256 requiredLzToken,
        uint256 suppliedLzToken
    );
    error ZeroLzTokenFee();
}

File 26 of 39 : PacketV1Codec.sol
// SPDX-License-Identifier: LZBL-1.2

pragma solidity ^0.8.22;

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 27 of 39 : 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 28 of 39 : 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 29 of 39 : 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 30 of 39 : 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 31 of 39 : 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 32 of 39 : 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 33 of 39 : 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 34 of 39 : 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 35 of 39 : ICreditMessaging.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { MessagingFee } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oft/interfaces/IOFT.sol";

/// @notice Stores the information related to a batch of credit transfers.
struct TargetCreditBatch {
    uint16 assetId;
    TargetCredit[] credits;
}

/// @notice Stores the information related to a single credit transfer.
struct TargetCredit {
    uint32 srcEid;
    uint64 amount; // the amount of credits to intended to send
    uint64 minAmount; // the minimum amount of credits to keep on local chain after sending
}

/// @title Credit Messaging API
/// @dev This interface defines the API for quoting and sending credits to other chains.
interface ICreditMessaging {
    /// @notice Sends credits to the destination endpoint.
    /// @param _dstEid The destination LayerZero endpoint ID.
    /// @param _creditBatches The credit batch payloads to send to the destination LayerZero endpoint ID.
    function sendCredits(uint32 _dstEid, TargetCreditBatch[] calldata _creditBatches) external payable;

    /// @notice Quotes the fee for sending credits to the destination endpoint.
    /// @param _dstEid The destination LayerZero endpoint ID.
    /// @param _creditBatches The credit batch payloads to send to the destination LayerZero endpoint ID.
    /// @return fee The fee for sending the credits to the destination endpoint.
    function quoteSendCredits(
        uint32 _dstEid,
        TargetCreditBatch[] calldata _creditBatches
    ) external view returns (MessagingFee memory fee);
}

File 36 of 39 : ICreditMessagingHandler.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { TargetCredit } from "./ICreditMessaging.sol";

struct Credit {
    uint32 srcEid;
    uint64 amount;
}

/// @dev This is an internal interface, defining functions to handle messages/calls from the credit messaging contract.
interface ICreditMessagingHandler {
    function sendCredits(uint32 _dstEid, TargetCredit[] calldata _credits) external returns (Credit[] memory);

    function receiveCredits(uint32 _srcEid, Credit[] calldata _credits) external;
}

File 37 of 39 : CreditMsgCodec.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;

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

import { Credit } from "../interfaces/ICreditMessagingHandler.sol";

struct CreditBatch {
    uint16 assetId;
    Credit[] credits;
}

library CreditMsgCodec {
    using Buffer for Buffer.buffer;
    using SafeCast for uint256;

    /// @dev The byte width of the amount field in the credit message.
    uint8 internal constant AMOUNT_BYTE_WIDTH = 8;

    /// @dev The byte width of the assetId field in the credit message.
    uint8 internal constant ASSET_ID_BYTE_WIDTH = 2;

    /// @dev The byte width of the srcEid field in the credit message.
    uint8 internal constant EID_BYTE_WIDTH = 4;

    /// @dev The byte width of the numBatches field in the credit message.
    uint8 internal constant NUM_BATCHES_BYTE_WIDTH = 1;

    /// @dev The byte width of the numCredits field in the credit batch.
    uint8 internal constant NUM_CREDITS_BYTE_WIDTH = 1;

    error CreditMsgCodec_InvalidMessage();

    function encode(
        CreditBatch[] memory _creditBatches,
        uint256 _totalCreditNum
    ) internal pure returns (bytes memory message) {
        uint256 numBatches = _creditBatches.length;
        // batchNum(1) + batchNum * (assetId(2) + batchSize(1)) + creditNum * (srcEid(4) + amount(8))
        uint256 bufferSize = NUM_BATCHES_BYTE_WIDTH +
            numBatches *
            (NUM_CREDITS_BYTE_WIDTH + ASSET_ID_BYTE_WIDTH) +
            _totalCreditNum *
            (EID_BYTE_WIDTH + AMOUNT_BYTE_WIDTH);
        Buffer.buffer memory buf;
        buf.init(bufferSize);
        buf.appendUint8(numBatches.toUint8());
        for (uint256 i = 0; i < numBatches; i++) {
            CreditBatch memory batch = _creditBatches[i];
            buf.appendInt(batch.assetId, ASSET_ID_BYTE_WIDTH);
            uint256 batchSize = batch.credits.length;
            buf.appendUint8(batchSize.toUint8());
            for (uint256 j = 0; j < batchSize; j++) {
                Credit memory credit = batch.credits[j];
                buf.appendInt(credit.srcEid, EID_BYTE_WIDTH);
                buf.appendInt(credit.amount, AMOUNT_BYTE_WIDTH);
            }
        }
        message = buf.buf;
    }

    function decode(bytes calldata _message) internal pure returns (CreditBatch[] memory creditBatches) {
        uint8 batchNum = uint8(_message[0]);
        creditBatches = new CreditBatch[](batchNum);
        uint256 cursor = 1; // skip batchNum(1)
        for (uint256 i = 0; i < batchNum; i++) {
            uint16 assetId = uint16(bytes2(_message[cursor:cursor += ASSET_ID_BYTE_WIDTH]));
            uint8 batchSize = uint8(_message[cursor]);
            cursor += NUM_BATCHES_BYTE_WIDTH;
            Credit[] memory credits = new Credit[](batchSize);
            for (uint256 j = 0; j < batchSize; j++) {
                uint32 srcEid = uint32(bytes4(_message[cursor:cursor += EID_BYTE_WIDTH]));
                uint64 amount = uint64(bytes8(_message[cursor:cursor += AMOUNT_BYTE_WIDTH]));
                credits[j] = Credit(srcEid, amount);
            }
            creditBatches[i] = CreditBatch(assetId, credits);
        }
        if (cursor != _message.length) revert CreditMsgCodec_InvalidMessage();
    }
}

File 38 of 39 : CreditMessagingOptions.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;

import { OAppOptionsType3 } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/libs/OAppOptionsType3.sol";
import { Buffer } from "@ensdomains/buffer/contracts/Buffer.sol";

/// @title Credit Messaging implementation of OAppOptionsType3
/// @notice This contract is used to build options for the CreditMessaging OApp.
abstract contract CreditMessagingOptions is OAppOptionsType3 {
    using Buffer for Buffer.buffer;

    /// @dev CreditMessaging only has one type of message.
    uint8 internal constant MSG_TYPE_CREDIT_MESSAGING = 3; // only one message type for credit messaging

    uint8 internal constant EXECUTOR_WORKER_ID = 1;
    uint8 internal constant OPTION_TYPE_LZRECEIVE = 1;
    uint16 internal constant OPTION_LZRECEIVE_PARAMS_SIZE = 17; // type(1) + gas(16)

    /// @dev The base gas limit for each endpoint.
    mapping(uint32 eid => uint128 gasLimit) public gasLimits;

    /// @notice Event emitted when the gas limit is set for a given endpoint.
    /// @param eid The LayerZero endpoint ID.
    /// @param gasLimit The base gas limit for the destination endpoint.
    event GasLimitSet(uint32 eid, uint128 gasLimit);

    /// @notice Error message for when the gas limit is not set for a given endpoint.
    /// @dev Zero gas limit is considered not set.
    error MessagingOptions_ZeroGasLimit();

    /// @notice Sets the base gas limit for a specific endpoint.  Sending a LayerZero message takes some constant amount
    /// of base gas regardless of the number of credits being sent in a particular message.  This function allows the
    /// CreditMessaging OApp to set the base gas limit.
    /// @param _eid The LayerZero endpoint ID.
    /// @param _gasLimit The base gas limit for the destination endpoint.
    function setGasLimit(uint32 _eid, uint128 _gasLimit) external onlyOwner {
        gasLimits[_eid] = _gasLimit;
        emit GasLimitSet(_eid, _gasLimit);
    }

    /// @notice Build the options for a credit messaging transaction.
    /// @param _eid The LayerZero endpoint ID.
    /// @param _totalCreditNum The total number of credits being sent in the message.
    /// @return options The options for the message.
    /// @dev The options are built by appending the lzReceive option to the enforced options for the given endpoint.
    function _buildOptions(uint32 _eid, uint128 _totalCreditNum) internal view returns (bytes memory options) {
        uint128 gasLimit = _safeGetGasLimit(_eid) * _totalCreditNum;
        options = enforcedOptions[_eid][MSG_TYPE_CREDIT_MESSAGING];

        // append lzReceive option
        options = options.length == 0
            ? abi.encodePacked(
                OPTION_TYPE_3,
                EXECUTOR_WORKER_ID,
                OPTION_LZRECEIVE_PARAMS_SIZE,
                OPTION_TYPE_LZRECEIVE,
                gasLimit
            )
            : abi.encodePacked(
                options,
                EXECUTOR_WORKER_ID,
                OPTION_LZRECEIVE_PARAMS_SIZE,
                OPTION_TYPE_LZRECEIVE,
                gasLimit
            );
    }

    /// @notice Safely retrieves the base gas limit for a given endpoint.  The base gas limit is the constant amount of
    /// gas required to send a message to the endpoint, regardless of the number of credits being sent.
    /// @param _eid The LayerZero endpoint ID.
    /// @return gasLimit The gas limit for the destination endpoint.
    /// @dev If the gas limit is not set, this function will revert.
    function _safeGetGasLimit(uint32 _eid) private view returns (uint128 gasLimit) {
        gasLimit = gasLimits[_eid];
        if (gasLimit == 0) revert MessagingOptions_ZeroGasLimit();
    }
}

File 39 of 39 : MessagingBase.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;

import { OApp, Origin } from "@layerzerolabs/lz-evm-oapp-v2/contracts/oapp/OApp.sol";
import { OAppPreCrimeSimulator } from "@layerzerolabs/lz-evm-oapp-v2/contracts/precrime/OAppPreCrimeSimulator.sol";

abstract contract MessagingBase is OApp, OAppPreCrimeSimulator {
    // max asset id, for the off-chain to get the range of asset id and get the list of stargate impls
    uint16 public maxAssetId;
    mapping(address stargateImpl => uint16 assetId) public assetIds;
    mapping(uint16 assetId => address stargateImpl) public stargateImpls;

    address public planner;

    event AssetIdSet(address stargateImpl, uint16 assetId);
    event MaxAssetIdSet(uint16 maxAssetId);
    event PlannerSet(address planner);

    error Messaging_Unauthorized();
    error Messaging_Unavailable();
    error Messaging_InvalidAssetId();

    modifier onlyPlanner() {
        if (msg.sender != planner) revert Messaging_Unauthorized();
        _;
    }

    constructor(address _endpoint, address _owner) OApp(_endpoint, _owner) {}

    // ---------------------------------- Only Owner ------------------------------------------

    function setAssetId(address _stargateImpl, uint16 _assetId) external onlyOwner {
        if (_assetId == 0) revert Messaging_InvalidAssetId();
        if (_assetId > maxAssetId) {
            maxAssetId = _assetId;
            emit MaxAssetIdSet(_assetId);
        }

        // clean up the old stargate
        uint16 oldAssetId = assetIds[_stargateImpl];
        address oldStargateImpl = stargateImpls[_assetId];
        if (oldAssetId != 0) delete stargateImpls[oldAssetId];
        if (oldStargateImpl != address(0)) delete assetIds[oldStargateImpl];

        // if stargateImpl is address(0) then delete stargateImpls[_assetId]
        if (_stargateImpl == address(0)) {
            delete stargateImpls[_assetId];
        } else {
            // set the new stargate
            assetIds[_stargateImpl] = _assetId;
            stargateImpls[_assetId] = _stargateImpl;
        }
        emit AssetIdSet(_stargateImpl, _assetId);
    }

    /// @dev Update the max asset id manually if it is not set correctly
    function setMaxAssetId(uint16 _maxAssetId) external onlyOwner {
        maxAssetId = _maxAssetId;
        emit MaxAssetIdSet(_maxAssetId);
    }

    function setPlanner(address _planner) external onlyOwner {
        planner = _planner;
        emit PlannerSet(_planner);
    }

    // ---------------------------------- Internal Functions ------------------------------------------

    function _safeGetStargateImpl(uint16 _assetId) internal view returns (address stargate) {
        stargate = stargateImpls[_assetId];
        if (stargate == address(0)) revert Messaging_Unavailable();
    }

    function _safeGetAssetId(address _stargateImpl) internal view returns (uint16 assetId) {
        assetId = assetIds[_stargateImpl];
        if (assetId == 0) revert Messaging_Unavailable();
    }

    /// @dev Lz token is payed in the stargate contract and do nothing here.
    /// Function meant to be overridden
    // solhint-disable-next-line no-empty-blocks
    function _payLzToken(uint256 /*_lzTokenFee*/) internal pure override {}

    // ---------------------------------- PreCrime Functions ------------------------------------------
    function _lzReceiveSimulate(
        Origin calldata _origin,
        bytes32 _guid,
        bytes calldata _message,
        address _executor,
        bytes calldata _extraData
    ) internal override {
        _lzReceive(_origin, _guid, _message, _executor, _extraData);
    }

    function isPeer(uint32 _eid, bytes32 _peer) public view override returns (bool) {
        return _peer == peers[_eid];
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_endpoint","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CreditMsgCodec_InvalidMessage","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[{"internalType":"bytes","name":"options","type":"bytes"}],"name":"InvalidOptions","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[],"name":"MessagingOptions_ZeroGasLimit","type":"error"},{"inputs":[],"name":"Messaging_InvalidAssetId","type":"error"},{"inputs":[],"name":"Messaging_Unauthorized","type":"error"},{"inputs":[],"name":"Messaging_Unavailable","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"NoPeer","type":"error"},{"inputs":[{"internalType":"uint256","name":"msgValue","type":"uint256"}],"name":"NotEnoughNative","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"OnlyEndpoint","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"OnlyPeer","type":"error"},{"inputs":[],"name":"OnlySelf","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"SimulationResult","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stargateImpl","type":"address"},{"indexed":false,"internalType":"uint16","name":"assetId","type":"uint16"}],"name":"AssetIdSet","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"indexed":false,"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"EnforcedOptionSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"eid","type":"uint32"},{"indexed":false,"internalType":"uint128","name":"gasLimit","type":"uint128"}],"name":"GasLimitSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"maxAssetId","type":"uint16"}],"name":"MaxAssetIdSet","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":"uint32","name":"eid","type":"uint32"},{"indexed":false,"internalType":"bytes32","name":"peer","type":"bytes32"}],"name":"PeerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"planner","type":"address"}],"name":"PlannerSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"preCrimeAddress","type":"address"}],"name":"PreCrimeSet","type":"event"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"}],"name":"allowInitializePath","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"stargateImpl","type":"address"}],"name":"assetIds","outputs":[{"internalType":"uint16","name":"assetId","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint16","name":"_msgType","type":"uint16"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"}],"name":"combineOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpointV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"}],"name":"enforcedOptions","outputs":[{"internalType":"bytes","name":"enforcedOption","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"gasLimits","outputs":[{"internalType":"uint128","name":"gasLimit","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"","type":"tuple"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"address","name":"_sender","type":"address"}],"name":"isComposeMsgSender","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"isPeer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"executor","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct InboundPacket[]","name":"_packets","type":"tuple[]"}],"name":"lzReceiveAndRevert","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceiveSimulate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"maxAssetId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"nextNonce","outputs":[{"internalType":"uint64","name":"nonce","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oApp","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oAppVersion","outputs":[{"internalType":"uint64","name":"senderVersion","type":"uint64"},{"internalType":"uint64","name":"receiverVersion","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"peers","outputs":[{"internalType":"bytes32","name":"peer","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"planner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preCrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"uint64","name":"amount","type":"uint64"},{"internalType":"uint64","name":"minAmount","type":"uint64"}],"internalType":"struct TargetCredit[]","name":"credits","type":"tuple[]"}],"internalType":"struct TargetCreditBatch[]","name":"_creditBatches","type":"tuple[]"}],"name":"quoteSendCredits","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"components":[{"internalType":"uint16","name":"assetId","type":"uint16"},{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"uint64","name":"amount","type":"uint64"},{"internalType":"uint64","name":"minAmount","type":"uint64"}],"internalType":"struct TargetCredit[]","name":"credits","type":"tuple[]"}],"internalType":"struct TargetCreditBatch[]","name":"_creditBatches","type":"tuple[]"}],"name":"sendCredits","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_stargateImpl","type":"address"},{"internalType":"uint16","name":"_assetId","type":"uint16"}],"name":"setAssetId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"}],"name":"setDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"setEnforcedOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint128","name":"_gasLimit","type":"uint128"}],"name":"setGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_maxAssetId","type":"uint16"}],"name":"setMaxAssetId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"setPeer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_planner","type":"address"}],"name":"setPlanner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_preCrime","type":"address"}],"name":"setPreCrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"assetId","type":"uint16"}],"name":"stargateImpls","outputs":[{"internalType":"address","name":"stargateImpl","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b5060405162003b3d38038062003b3d83398101604081905262000034916200014f565b8181818181816200004533620000e2565b6001600160a01b0380831660805281166200007357604051632d618d8160e21b815260040160405180910390fd5b60805160405163ca5eb5e160e01b81526001600160a01b0383811660048301529091169063ca5eb5e190602401600060405180830381600087803b158015620000bb57600080fd5b505af1158015620000d0573d6000803e3d6000fd5b50505050505050505050505062000187565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200014a57600080fd5b919050565b600080604083850312156200016357600080fd5b6200016e8362000132565b91506200017e6020840162000132565b90509250929050565b60805161397e620001bf600039600081816102fe015281816106cd0152818161150d01528181611d140152611e6a015261397e6000f3fe6080604052600436106101e35760003560e01c80638f71f7dd11610102578063ca5eb5e111610095578063e4c572cc11610064578063e4c572cc1461060b578063f2fde38b1461062b578063f8d50da61461064b578063ff7bd03d146106ab57600080fd5b8063ca5eb5e114610587578063d045a0dc146105a7578063d4243885146105ba578063d8e8dbc7146105da57600080fd5b8063b98bd070116100d1578063b98bd070146104f9578063bb0b6a5314610519578063bc70b35414610554578063bd815db01461057457600080fd5b80638f71f7dd14610438578063917df23b14610458578063b731ea0a1461049e578063b76cbd7d146104be57600080fd5b80635f6d9ae41161017a5780637d25a05e116101495780637d25a05e1461039e57806382413eac146103da578063826f1fb1146103fa5780638da5cb5b1461041a57600080fd5b80635f6d9ae41461032057806365b9bacb146103565780637048515514610376578063715018a61461038957600080fd5b806352ae2879116101b657806352ae28791461027c5780635535d4611461028f5780635a0dfe4d146102bc5780635e280f11146102ec57600080fd5b806313137d65146101e857806317442b70146101fd57806332e4e363146102245780633400288b1461025c575b600080fd5b6101fb6101f636600461277f565b6106cb565b005b34801561020957600080fd5b50604080516001815260026020820152015b60405180910390f35b34801561023057600080fd5b50600554610244906001600160a01b031681565b6040516001600160a01b03909116815260200161021b565b34801561026857600080fd5b506101fb610277366004612830565b6107bd565b34801561028857600080fd5b5030610244565b34801561029b57600080fd5b506102af6102aa36600461286e565b6107d3565b60405161021b91906128f3565b3480156102c857600080fd5b506102dc6102d7366004612830565b610878565b604051901515815260200161021b565b3480156102f857600080fd5b506102447f000000000000000000000000000000000000000000000000000000000000000081565b34801561032c57600080fd5b5061024461033b366004612906565b6004602052600090815260409020546001600160a01b031681565b34801561036257600080fd5b506101fb610371366004612921565b610897565b6101fb6103843660046129b4565b61092e565b34801561039557600080fd5b506101fb610b79565b3480156103aa57600080fd5b506103c16103b9366004612830565b600092915050565b60405167ffffffffffffffff909116815260200161021b565b3480156103e657600080fd5b506102dc6103f5366004612a09565b610b8d565b34801561040657600080fd5b506101fb610415366004612a6f565b610ba2565b34801561042657600080fd5b506000546001600160a01b0316610244565b34801561044457600080fd5b506101fb610453366004612a8a565b610c17565b34801561046457600080fd5b5060025461048b9074010000000000000000000000000000000000000000900461ffff1681565b60405161ffff909116815260200161021b565b3480156104aa57600080fd5b50600254610244906001600160a01b031681565b3480156104ca57600080fd5b506104de6104d93660046129b4565b610ed9565b6040805182518152602092830151928101929092520161021b565b34801561050557600080fd5b506101fb610514366004612aa6565b611166565b34801561052557600080fd5b50610546610534366004612ae8565b60016020526000908152604090205481565b60405190815260200161021b565b34801561056057600080fd5b506102af61056f366004612b05565b611180565b6101fb610582366004612aa6565b611341565b34801561059357600080fd5b506101fb6105a2366004612a6f565b6114cd565b6101fb6105b536600461277f565b61156c565b3480156105c657600080fd5b506101fb6105d5366004612a6f565b6115b4565b3480156105e657600080fd5b5061048b6105f5366004612a6f565b60036020526000908152604090205461ffff1681565b34801561061757600080fd5b506101fb610626366004612906565b611622565b34801561063757600080fd5b506101fb610646366004612a6f565b6116a5565b34801561065757600080fd5b5061068a610666366004612ae8565b6007602052600090815260409020546fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff909116815260200161021b565b3480156106b757600080fd5b506102dc6106c6366004612b68565b61174f565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163314610734576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b6020870180359061074e90610749908a612ae8565b611785565b146107a5576107606020880188612ae8565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff90911660048201526020880135602482015260440161072b565b6107b4878787878787876117da565b50505050505050565b6107c56118a9565b6107cf828261191d565b5050565b6006602090815260009283526040808420909152908252902080546107f790612b84565b80601f016020809104026020016040519081016040528092919081815260200182805461082390612b84565b80156108705780601f1061084557610100808354040283529160200191610870565b820191906000526020600020905b81548152906001019060200180831161085357829003601f168201915b505050505081565b63ffffffff821660009081526001602052604090205481145b92915050565b61089f6118a9565b63ffffffff821660008181526007602090815260409182902080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff86169081179091558251938452908301527f2de2cdf6b9f29bfb9afedda6cf015c5fcb9832c9c0c3dcc06d501d964cf5653791015b60405180910390a15050565b6005546001600160a01b03163314610972576040517fc63aab2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008167ffffffffffffffff81111561098d5761098d612bd1565b6040519080825280602002602001820160405280156109d357816020015b6040805180820190915260008152606060208201528152602001906001900390816109ab5790505b50905060008060005b84811015610b1357368686838181106109f7576109f7612c00565b9050602002810190610a099190612c2f565b90506000610a22610a1d6020840184612906565b61196b565b6001600160a01b0316630141e41b8a610a3e6020860186612c6d565b6040518463ffffffff1660e01b8152600401610a5c93929190612cea565b6000604051808303816000875af1158015610a7b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610aa39190810190612e18565b805190915015610b09576040805180820190915280610ac56020850185612906565b61ffff1681526020018290528686610adc81612f0a565b975081518110610aee57610aee612c00565b6020026020010181905250805184610b069190612f24565b93505b50506001016109dc565b508115610b71578183526000610b3b84836fffffffffffffffffffffffffffffffff166119c4565b90506000610b498884611b38565b9050610b6d8883836040518060400160405280348152602001600081525033611cf9565b5050505b505050505050565b610b816118a9565b610b8b6000611dec565b565b6001600160a01b03811630145b949350505050565b610baa6118a9565b600580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5767d79cd17d7554509a4dd59a5a7a9175c7e36466455d7b2fa4788228808579906020015b60405180910390a150565b610c1f6118a9565b8061ffff16600003610c5d576040517fe447547600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025461ffff7401000000000000000000000000000000000000000090910481169082161115610d0657600280547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c0179060200160405180910390a15b6001600160a01b0380831660009081526003602090815260408083205461ffff86811685526004909352922054911691168115610d775761ffff8216600090815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b6001600160a01b03811615610dc5576001600160a01b038116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690555b6001600160a01b038416610e115761ffff8316600090815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055610e8e565b6001600160a01b038416600081815260036020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff891690811790915583526004909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690911790555b604080516001600160a01b038616815261ffff851660208201527fac53470cf8e9e3d673caa7d47cd7db36c0d38cf37fc147c70c92bc0c1c4734f5910160405180910390a150505050565b604080518082019091526000808252602082015260008267ffffffffffffffff811115610f0857610f08612bd1565b604051908082528060200260200182016040528015610f4e57816020015b604080518082019091526000815260606020820152815260200190600190039081610f265790505b5090506000805b8481101561111e57366000878784818110610f7257610f72612c00565b9050602002810190610f849190612c2f565b610f92906020810190612c6d565b909250905060008167ffffffffffffffff811115610fb257610fb2612bd1565b604051908082528060200260200182016040528015610ff757816020015b6040805180820190915260008082526020820152815260200190600190039081610fd05790505b5090506110048286612f24565b945060005b828110156110ab57604051806040016040528085858481811061102e5761102e612c00565b6110449260206060909202019081019150612ae8565b63ffffffff16815260200185858481811061106157611061612c00565b90506060020160200160208101906110799190612f54565b67ffffffffffffffff1681525082828151811061109857611098612c00565b6020908102919091010152600101611009565b5060405180604001604052808a8a878181106110c9576110c9612c00565b90506020028101906110db9190612c2f565b6110e9906020810190612906565b61ffff1681526020018281525086858151811061110857611108612c00565b6020908102919091010152505050600101610f55565b50600061113d83836fffffffffffffffffffffffffffffffff166119c4565b9050600061114b8884611b38565b905061115a8883836000611e54565b98975050505050505050565b61116e6118a9565b6107cf61117b8284612f99565b611f35565b63ffffffff8416600090815260066020908152604080832061ffff871684529091528120805460609291906111b490612b84565b80601f01602080910402602001604051908101604052809291908181526020018280546111e090612b84565b801561122d5780601f106112025761010080835404028352916020019161122d565b820191906000526020600020905b81548152906001019060200180831161121057829003601f168201915b50505050509050805160000361127d5783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929450610b9a9350505050565b600083900361128d579050610b9a565b6002831061130b576112d484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061203c92505050565b806112e284600281886130a5565b6040516020016112f4939291906130cf565b604051602081830303815290604052915050610b9a565b83836040517f9a6d49cd00000000000000000000000000000000000000000000000000000000815260040161072b929190613122565b60005b81811015611433573683838381811061135f5761135f612c00565b90506020028101906113719190613136565b905061138d6113836020830183612ae8565b6020830135610878565b611397575061142b565b3063d045a0dc60c08301358360a08101356113b661010083018361316a565b6113c7610100890160e08a01612a6f565b6113d56101208a018a61316a565b6040518963ffffffff1660e01b81526004016113f797969594939291906131cf565b6000604051808303818588803b15801561141057600080fd5b505af1158015611424573d6000803e3d6000fd5b5050505050505b600101611344565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611472573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261149a9190810190613258565b6040517f8351eea700000000000000000000000000000000000000000000000000000000815260040161072b91906128f3565b6114d56118a9565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ca5eb5e190602401600060405180830381600087803b15801561155157600080fd5b505af1158015611565573d6000803e3d6000fd5b5050505050565b3330146115a5576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107b4878787878787876107a5565b6115bc6118a9565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001610c0c565b61162a6118a9565b600280547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c01790602001610c0c565b6116ad6118a9565b6001600160a01b038116611743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161072b565b61174c81611dec565b50565b60006020820180359060019083906117679086612ae8565b63ffffffff1681526020810191909152604001600020541492915050565b63ffffffff811660009081526001602052604081205480610891576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff8416600482015260240161072b565b60006117e68686612081565b805190915060005b8181101561189d57600083828151811061180a5761180a612c00565b60200260200101519050611821816000015161196b565b6001600160a01b0316639561b12f61183c60208e018e612ae8565b83602001516040518363ffffffff1660e01b815260040161185e9291906132c6565b600060405180830381600087803b15801561187857600080fd5b505af115801561188c573d6000803e3d6000fd5b5050600190930192506117ee915050565b50505050505050505050565b6000546001600160a01b03163314610b8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161072b565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b9101610922565b61ffff81166000908152600460205260409020546001600160a01b0316806119bf576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b815160609060006119d760086004613335565b6119e49060ff168561334e565b6119f060026001613335565b6119fd9060ff168461334e565b611a08906001613365565b611a129190613365565b9050611a31604051806040016040528060608152602001600081525090565b611a3b818361230e565b50611a4f611a4884612385565b829061241c565b5060005b83811015611b2d576000878281518110611a6f57611a6f612c00565b60209081029190910101518051909150611a9090849061ffff166002612485565b50602081015151611aaa611aa382612385565b859061241c565b5060005b81811015611b2257600083602001518281518110611ace57611ace612c00565b60200260200101519050611afb816000015163ffffffff16600460ff16886124859092919063ffffffff16565b506020810151611b1890879067ffffffffffffffff166008612485565b5050600101611aae565b505050600101611a53565b505195945050505050565b6060600082611b468561250a565b611b509190613378565b63ffffffff85166000908152600660209081526040808320600384529091529020805491925090611b8090612b84565b80601f0160208091040260200160405190810160405280929190818152602001828054611bac90612b84565b8015611bf95780601f10611bce57610100808354040283529160200191611bf9565b820191906000526020600020905b815481529060010190602001808311611bdc57829003601f168201915b505050505091508151600014611c39578160016011600184604051602001611c259594939291906133a4565b604051602081830303815290604052610b9a565b6040517e0300000000000000000000000000000000000000000000000000000000000060208201527f0100000000000000000000000000000000000000000000000000000000000000602282018190527e11000000000000000000000000000000000000000000000000000000000000602383015260258201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608083901b166026820152603601604051602081830303815290604052949350505050565b611d016126bf565b6000611d10846000015161256c565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001611d628c611785565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401611d9e929190613455565b60806040518083038185885af1158015611dbc573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611de1919061351c565b979650505050505050565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60408051808201909152600080825260208201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddc28c586040518060a001604052808863ffffffff168152602001611eb789611785565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b8152600401611eec929190613455565b6040805180830381865afa158015611f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2c9190613566565b95945050505050565b60005b815181101561200c57611f67828281518110611f5657611f56612c00565b60200260200101516040015161203c565b818181518110611f7957611f79612c00565b60200260200101516040015160066000848481518110611f9b57611f9b612c00565b60200260200101516000015163ffffffff1663ffffffff1681526020019081526020016000206000848481518110611fd557611fd5612c00565b60200260200101516020015161ffff1661ffff168152602001908152602001600020908161200391906135cf565b50600101611f38565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b67481604051610c0c919061368f565b600281015161ffff81166003146107cf57816040517f9a6d49cd00000000000000000000000000000000000000000000000000000000815260040161072b91906128f3565b606060008383600081811061209857612098612c00565b919091013560f81c915081905067ffffffffffffffff8111156120bd576120bd612bd1565b60405190808252806020026020018201604052801561210357816020015b6040805180820190915260008152606060208201528152602001906001900390816120db5790505b509150600160005b8260ff168110156122cc576000868387612126600283613365565b955061213592869291906130a5565b61213e91613738565b60f01c9050600087878581811061215757612157612c00565b919091013560f81c915061216e9050600185613365565b935060008160ff1667ffffffffffffffff81111561218e5761218e612bd1565b6040519080825280602002602001820160405280156121d357816020015b60408051808201909152600080825260208201528152602001906001900390816121ac5790505b50905060005b8260ff1681101561228a5760008a878b6121f4600483613365565b9950612203928a9291906130a5565b61220c9161377e565b60e01c905060008b888c612221600883613365565b9a50612230928b9291906130a5565b612239916137c4565b60c01c905060405180604001604052808363ffffffff1681526020018267ffffffffffffffff1681525084848151811061227557612275612c00565b602090810291909101015250506001016121d9565b5060405180604001604052808461ffff168152602001828152508785815181106122b6576122b6612c00565b602090810291909101015250505060010161210b565b50808414612306576040517fa7272c6200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b60408051808201909152606081526000602082015261232e60208361380a565b156123565761233e60208361380a565b612349906020613845565b6123539083613365565b91505b60208084018390526040518085526000815290818401018181101561237a57600080fd5b604052509192915050565b600060ff821115612418576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203860448201527f2062697473000000000000000000000000000000000000000000000000000000606482015260840161072b565b5090565b6040805180820190915260608152600060208201528251516000612441826001613365565b905084602001518210612462576124628561245d83600261334e565b6125a9565b845160208382010185815350805182111561247b578181525b5093949350505050565b60408051808201909152606081526000602082015283515160006124a98285613365565b905085602001518111156124c6576124c68661245d83600261334e565b600060016124d68661010061393c565b6124e09190613845565b905086518281018783198251161781525080518311156124fe578281525b50959695505050505050565b63ffffffff81166000908152600760205260408120546fffffffffffffffffffffffffffffffff16908190036119bf576040517fc960f36b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000813414612418576040517f9f70412000000000000000000000000000000000000000000000000000000000815234600482015260240161072b565b81516125b5838361230e565b506125c083826125c6565b50505050565b6040805180820190915260608152600060208201526125e7838384516125ee565b9392505050565b604080518082019091526060815260006020820152825182111561261157600080fd5b83515160006126208483613365565b9050856020015181111561263d5761263d8661245d83600261334e565b855180518382016020019160009180851115612657578482525b505050602086015b602086106126975780518252612676602083613365565b9150612683602082613365565b9050612690602087613845565b955061265f565b51815160001960208890036101000a0190811690199190911617905250849150509392505050565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001612702604051806040016040528060008152602001600081525090565b905290565b60006060828403121561271957600080fd5b50919050565b60008083601f84011261273157600080fd5b50813567ffffffffffffffff81111561274957600080fd5b60208301915083602082850101111561276157600080fd5b9250929050565b80356001600160a01b03811681146119bf57600080fd5b600080600080600080600060e0888a03121561279a57600080fd5b6127a48989612707565b965060608801359550608088013567ffffffffffffffff808211156127c857600080fd5b6127d48b838c0161271f565b90975095508591506127e860a08b01612768565b945060c08a01359150808211156127fe57600080fd5b5061280b8a828b0161271f565b989b979a50959850939692959293505050565b63ffffffff8116811461174c57600080fd5b6000806040838503121561284357600080fd5b823561284e8161281e565b946020939093013593505050565b803561ffff811681146119bf57600080fd5b6000806040838503121561288157600080fd5b823561288c8161281e565b915061289a6020840161285c565b90509250929050565b60005b838110156128be5781810151838201526020016128a6565b50506000910152565b600081518084526128df8160208601602086016128a3565b601f01601f19169290920160200192915050565b6020815260006125e760208301846128c7565b60006020828403121561291857600080fd5b6125e78261285c565b6000806040838503121561293457600080fd5b823561293f8161281e565b915060208301356fffffffffffffffffffffffffffffffff8116811461296457600080fd5b809150509250929050565b60008083601f84011261298157600080fd5b50813567ffffffffffffffff81111561299957600080fd5b6020830191508360208260051b850101111561276157600080fd5b6000806000604084860312156129c957600080fd5b83356129d48161281e565b9250602084013567ffffffffffffffff8111156129f057600080fd5b6129fc8682870161296f565b9497909650939450505050565b60008060008060a08587031215612a1f57600080fd5b612a298686612707565b9350606085013567ffffffffffffffff811115612a4557600080fd5b612a518782880161271f565b9094509250612a64905060808601612768565b905092959194509250565b600060208284031215612a8157600080fd5b6125e782612768565b60008060408385031215612a9d57600080fd5b61288c83612768565b60008060208385031215612ab957600080fd5b823567ffffffffffffffff811115612ad057600080fd5b612adc8582860161296f565b90969095509350505050565b600060208284031215612afa57600080fd5b81356125e78161281e565b60008060008060608587031215612b1b57600080fd5b8435612b268161281e565b9350612b346020860161285c565b9250604085013567ffffffffffffffff811115612b5057600080fd5b612b5c8782880161271f565b95989497509550505050565b600060608284031215612b7a57600080fd5b6125e78383612707565b600181811c90821680612b9857607f821691505b602082108103612719577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112612c6357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612ca257600080fd5b83018035915067ffffffffffffffff821115612cbd57600080fd5b602001915060608102360382131561276157600080fd5b67ffffffffffffffff8116811461174c57600080fd5b63ffffffff84811682526040602080840182905283820185905260009260609182860188865b89811015612d67578135612d238161281e565b8516835281840135612d3481612cd4565b67ffffffffffffffff908116848601528288013590612d5282612cd4565b16838801529185019190850190600101612d10565b50909a9950505050505050505050565b6040805190810167ffffffffffffffff81118282101715612d9a57612d9a612bd1565b60405290565b6040516060810167ffffffffffffffff81118282101715612d9a57612d9a612bd1565b604051601f8201601f1916810167ffffffffffffffff81118282101715612dec57612dec612bd1565b604052919050565b600067ffffffffffffffff821115612e0e57612e0e612bd1565b5060051b60200190565b60006020808385031215612e2b57600080fd5b825167ffffffffffffffff811115612e4257600080fd5b8301601f81018513612e5357600080fd5b8051612e66612e6182612df4565b612dc3565b81815260069190911b82018301908381019087831115612e8557600080fd5b928401925b82841015611de15760408489031215612ea35760008081fd5b612eab612d77565b8451612eb68161281e565b815284860151612ec581612cd4565b8187015282526040939093019290840190612e8a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006000198203612f1d57612f1d612edb565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115612f4d57612f4d612edb565b5092915050565b600060208284031215612f6657600080fd5b81356125e781612cd4565b600067ffffffffffffffff821115612f8b57612f8b612bd1565b50601f01601f191660200190565b6000612fa7612e6184612df4565b80848252602080830192508560051b850136811115612fc557600080fd5b855b8181101561309957803567ffffffffffffffff80821115612fe85760008081fd5b818901915060608236031215612ffe5760008081fd5b613006612da0565b82356130118161281e565b815261301e83870161285c565b86820152604080840135838111156130365760008081fd5b939093019236601f85011261304d57600092508283fd5b8335925061305d612e6184612f71565b83815236888587010111156130725760008081fd5b83888601898301376000938101880193909352810191909152865250938201938201612fc7565b50919695505050505050565b600080858511156130b557600080fd5b838611156130c257600080fd5b5050820193919092039150565b600084516130e18184602089016128a3565b8201838582376000930192835250909392505050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b602081526000610b9a6020830184866130f7565b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec1833603018112612c6357600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261319f57600080fd5b83018035915067ffffffffffffffff8211156131ba57600080fd5b60200191503681900382131561276157600080fd5b600088356131dc8161281e565b63ffffffff1682526020898101359083015260408901356131fc81612cd4565b67ffffffffffffffff811660408401525087606083015260e0608083015261322860e0830187896130f7565b6001600160a01b03861660a084015282810360c084015261324a8185876130f7565b9a9950505050505050505050565b60006020828403121561326a57600080fd5b815167ffffffffffffffff81111561328157600080fd5b8201601f8101841361329257600080fd5b80516132a0612e6182612f71565b8181528560208385010111156132b557600080fd5b611f2c8260208301602086016128a3565b6000604080830163ffffffff808716855260206040602087015282875180855260608801915060208901945060005b8181101561332657855180518616845284015167ffffffffffffffff168484015294830194918601916001016132f5565b50909998505050505050505050565b60ff818116838216019081111561089157610891612edb565b808202811582820484141761089157610891612edb565b8082018082111561089157610891612edb565b6fffffffffffffffffffffffffffffffff81811683821602808216919082811461230657612306612edb565b600086516133b6818460208b016128a3565b60f896871b7fff000000000000000000000000000000000000000000000000000000000000009081169390910192835260f09590951b7fffff000000000000000000000000000000000000000000000000000000000000166001830152509190931b909116600382015260809190911b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166004820152601401919050565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a0608084015261348b60e08401826128c7565b905060608501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08483030160a08501526134c682826128c7565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b6000604082840312156134fe57600080fd5b613506612d77565b9050815181526020820151602082015292915050565b60006080828403121561352e57600080fd5b613536612da0565b82518152602083015161354881612cd4565b602082015261355a84604085016134ec565b60408201529392505050565b60006040828403121561357857600080fd5b6125e783836134ec565b601f8211156135ca576000816000526020600020601f850160051c810160208610156135ab5750805b601f850160051c820191505b81811015610b71578281556001016135b7565b505050565b815167ffffffffffffffff8111156135e9576135e9612bd1565b6135fd816135f78454612b84565b84613582565b602080601f831160018114613632576000841561361a5750858301515b600019600386901b1c1916600185901b178555610b71565b600085815260208120601f198616915b8281101561366157888601518255948401946001909101908401613642565b508582101561367f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561372a578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805163ffffffff1684528781015161ffff16888501528601516060878501819052613716818601836128c7565b9689019694505050908601906001016136b8565b509098975050505050505050565b7fffff00000000000000000000000000000000000000000000000000000000000081358181169160028510156123065760029490940360031b84901b1690921692915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156123065760049490940360031b84901b1690921692915050565b7fffffffffffffffff00000000000000000000000000000000000000000000000081358181169160088510156123065760089490940360031b84901b1690921692915050565b600082613840577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8181038181111561089157610891612edb565b600181815b8085111561389357816000190482111561387957613879612edb565b8085161561388657918102915b93841c939080029061385d565b509250929050565b6000826138aa57506001610891565b816138b757506000610891565b81600181146138cd57600281146138d7576138f3565b6001915050610891565b60ff8411156138e8576138e8612edb565b50506001821b610891565b5060208310610133831016604e8410600b8410161715613916575081810a610891565b6139208383613858565b806000190482111561393457613934612edb565b029392505050565b60006125e7838361389b56fea2646970667358221220626c4561e4bc699b85f4a1ad821a89d68653b23e8fd1f94604840d7d4e69f49c64736f6c634300081600330000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc24

Deployed Bytecode

0x6080604052600436106101e35760003560e01c80638f71f7dd11610102578063ca5eb5e111610095578063e4c572cc11610064578063e4c572cc1461060b578063f2fde38b1461062b578063f8d50da61461064b578063ff7bd03d146106ab57600080fd5b8063ca5eb5e114610587578063d045a0dc146105a7578063d4243885146105ba578063d8e8dbc7146105da57600080fd5b8063b98bd070116100d1578063b98bd070146104f9578063bb0b6a5314610519578063bc70b35414610554578063bd815db01461057457600080fd5b80638f71f7dd14610438578063917df23b14610458578063b731ea0a1461049e578063b76cbd7d146104be57600080fd5b80635f6d9ae41161017a5780637d25a05e116101495780637d25a05e1461039e57806382413eac146103da578063826f1fb1146103fa5780638da5cb5b1461041a57600080fd5b80635f6d9ae41461032057806365b9bacb146103565780637048515514610376578063715018a61461038957600080fd5b806352ae2879116101b657806352ae28791461027c5780635535d4611461028f5780635a0dfe4d146102bc5780635e280f11146102ec57600080fd5b806313137d65146101e857806317442b70146101fd57806332e4e363146102245780633400288b1461025c575b600080fd5b6101fb6101f636600461277f565b6106cb565b005b34801561020957600080fd5b50604080516001815260026020820152015b60405180910390f35b34801561023057600080fd5b50600554610244906001600160a01b031681565b6040516001600160a01b03909116815260200161021b565b34801561026857600080fd5b506101fb610277366004612830565b6107bd565b34801561028857600080fd5b5030610244565b34801561029b57600080fd5b506102af6102aa36600461286e565b6107d3565b60405161021b91906128f3565b3480156102c857600080fd5b506102dc6102d7366004612830565b610878565b604051901515815260200161021b565b3480156102f857600080fd5b506102447f0000000000000000000000001a44076050125825900e736c501f859c50fe728c81565b34801561032c57600080fd5b5061024461033b366004612906565b6004602052600090815260409020546001600160a01b031681565b34801561036257600080fd5b506101fb610371366004612921565b610897565b6101fb6103843660046129b4565b61092e565b34801561039557600080fd5b506101fb610b79565b3480156103aa57600080fd5b506103c16103b9366004612830565b600092915050565b60405167ffffffffffffffff909116815260200161021b565b3480156103e657600080fd5b506102dc6103f5366004612a09565b610b8d565b34801561040657600080fd5b506101fb610415366004612a6f565b610ba2565b34801561042657600080fd5b506000546001600160a01b0316610244565b34801561044457600080fd5b506101fb610453366004612a8a565b610c17565b34801561046457600080fd5b5060025461048b9074010000000000000000000000000000000000000000900461ffff1681565b60405161ffff909116815260200161021b565b3480156104aa57600080fd5b50600254610244906001600160a01b031681565b3480156104ca57600080fd5b506104de6104d93660046129b4565b610ed9565b6040805182518152602092830151928101929092520161021b565b34801561050557600080fd5b506101fb610514366004612aa6565b611166565b34801561052557600080fd5b50610546610534366004612ae8565b60016020526000908152604090205481565b60405190815260200161021b565b34801561056057600080fd5b506102af61056f366004612b05565b611180565b6101fb610582366004612aa6565b611341565b34801561059357600080fd5b506101fb6105a2366004612a6f565b6114cd565b6101fb6105b536600461277f565b61156c565b3480156105c657600080fd5b506101fb6105d5366004612a6f565b6115b4565b3480156105e657600080fd5b5061048b6105f5366004612a6f565b60036020526000908152604090205461ffff1681565b34801561061757600080fd5b506101fb610626366004612906565b611622565b34801561063757600080fd5b506101fb610646366004612a6f565b6116a5565b34801561065757600080fd5b5061068a610666366004612ae8565b6007602052600090815260409020546fffffffffffffffffffffffffffffffff1681565b6040516fffffffffffffffffffffffffffffffff909116815260200161021b565b3480156106b757600080fd5b506102dc6106c6366004612b68565b61174f565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b03163314610734576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b6020870180359061074e90610749908a612ae8565b611785565b146107a5576107606020880188612ae8565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff90911660048201526020880135602482015260440161072b565b6107b4878787878787876117da565b50505050505050565b6107c56118a9565b6107cf828261191d565b5050565b6006602090815260009283526040808420909152908252902080546107f790612b84565b80601f016020809104026020016040519081016040528092919081815260200182805461082390612b84565b80156108705780601f1061084557610100808354040283529160200191610870565b820191906000526020600020905b81548152906001019060200180831161085357829003601f168201915b505050505081565b63ffffffff821660009081526001602052604090205481145b92915050565b61089f6118a9565b63ffffffff821660008181526007602090815260409182902080547fffffffffffffffffffffffffffffffff00000000000000000000000000000000166fffffffffffffffffffffffffffffffff86169081179091558251938452908301527f2de2cdf6b9f29bfb9afedda6cf015c5fcb9832c9c0c3dcc06d501d964cf5653791015b60405180910390a15050565b6005546001600160a01b03163314610972576040517fc63aab2c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008167ffffffffffffffff81111561098d5761098d612bd1565b6040519080825280602002602001820160405280156109d357816020015b6040805180820190915260008152606060208201528152602001906001900390816109ab5790505b50905060008060005b84811015610b1357368686838181106109f7576109f7612c00565b9050602002810190610a099190612c2f565b90506000610a22610a1d6020840184612906565b61196b565b6001600160a01b0316630141e41b8a610a3e6020860186612c6d565b6040518463ffffffff1660e01b8152600401610a5c93929190612cea565b6000604051808303816000875af1158015610a7b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610aa39190810190612e18565b805190915015610b09576040805180820190915280610ac56020850185612906565b61ffff1681526020018290528686610adc81612f0a565b975081518110610aee57610aee612c00565b6020026020010181905250805184610b069190612f24565b93505b50506001016109dc565b508115610b71578183526000610b3b84836fffffffffffffffffffffffffffffffff166119c4565b90506000610b498884611b38565b9050610b6d8883836040518060400160405280348152602001600081525033611cf9565b5050505b505050505050565b610b816118a9565b610b8b6000611dec565b565b6001600160a01b03811630145b949350505050565b610baa6118a9565b600580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527f5767d79cd17d7554509a4dd59a5a7a9175c7e36466455d7b2fa4788228808579906020015b60405180910390a150565b610c1f6118a9565b8061ffff16600003610c5d576040517fe447547600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025461ffff7401000000000000000000000000000000000000000090910481169082161115610d0657600280547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c0179060200160405180910390a15b6001600160a01b0380831660009081526003602090815260408083205461ffff86811685526004909352922054911691168115610d775761ffff8216600090815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555b6001600160a01b03811615610dc5576001600160a01b038116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690555b6001600160a01b038416610e115761ffff8316600090815260046020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000169055610e8e565b6001600160a01b038416600081815260036020908152604080832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001661ffff891690811790915583526004909152902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001690911790555b604080516001600160a01b038616815261ffff851660208201527fac53470cf8e9e3d673caa7d47cd7db36c0d38cf37fc147c70c92bc0c1c4734f5910160405180910390a150505050565b604080518082019091526000808252602082015260008267ffffffffffffffff811115610f0857610f08612bd1565b604051908082528060200260200182016040528015610f4e57816020015b604080518082019091526000815260606020820152815260200190600190039081610f265790505b5090506000805b8481101561111e57366000878784818110610f7257610f72612c00565b9050602002810190610f849190612c2f565b610f92906020810190612c6d565b909250905060008167ffffffffffffffff811115610fb257610fb2612bd1565b604051908082528060200260200182016040528015610ff757816020015b6040805180820190915260008082526020820152815260200190600190039081610fd05790505b5090506110048286612f24565b945060005b828110156110ab57604051806040016040528085858481811061102e5761102e612c00565b6110449260206060909202019081019150612ae8565b63ffffffff16815260200185858481811061106157611061612c00565b90506060020160200160208101906110799190612f54565b67ffffffffffffffff1681525082828151811061109857611098612c00565b6020908102919091010152600101611009565b5060405180604001604052808a8a878181106110c9576110c9612c00565b90506020028101906110db9190612c2f565b6110e9906020810190612906565b61ffff1681526020018281525086858151811061110857611108612c00565b6020908102919091010152505050600101610f55565b50600061113d83836fffffffffffffffffffffffffffffffff166119c4565b9050600061114b8884611b38565b905061115a8883836000611e54565b98975050505050505050565b61116e6118a9565b6107cf61117b8284612f99565b611f35565b63ffffffff8416600090815260066020908152604080832061ffff871684529091528120805460609291906111b490612b84565b80601f01602080910402602001604051908101604052809291908181526020018280546111e090612b84565b801561122d5780601f106112025761010080835404028352916020019161122d565b820191906000526020600020905b81548152906001019060200180831161121057829003601f168201915b50505050509050805160000361127d5783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929450610b9a9350505050565b600083900361128d579050610b9a565b6002831061130b576112d484848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061203c92505050565b806112e284600281886130a5565b6040516020016112f4939291906130cf565b604051602081830303815290604052915050610b9a565b83836040517f9a6d49cd00000000000000000000000000000000000000000000000000000000815260040161072b929190613122565b60005b81811015611433573683838381811061135f5761135f612c00565b90506020028101906113719190613136565b905061138d6113836020830183612ae8565b6020830135610878565b611397575061142b565b3063d045a0dc60c08301358360a08101356113b661010083018361316a565b6113c7610100890160e08a01612a6f565b6113d56101208a018a61316a565b6040518963ffffffff1660e01b81526004016113f797969594939291906131cf565b6000604051808303818588803b15801561141057600080fd5b505af1158015611424573d6000803e3d6000fd5b5050505050505b600101611344565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611472573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261149a9190810190613258565b6040517f8351eea700000000000000000000000000000000000000000000000000000000815260040161072b91906128f3565b6114d56118a9565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c169063ca5eb5e190602401600060405180830381600087803b15801561155157600080fd5b505af1158015611565573d6000803e3d6000fd5b5050505050565b3330146115a5576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107b4878787878787876107a5565b6115bc6118a9565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c242776090602001610c0c565b61162a6118a9565b600280547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff167401000000000000000000000000000000000000000061ffff8416908102919091179091556040519081527f8f1145f51954bc9512a08693182e170a57b63ca4f6acc321b87c526970f4c01790602001610c0c565b6116ad6118a9565b6001600160a01b038116611743576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161072b565b61174c81611dec565b50565b60006020820180359060019083906117679086612ae8565b63ffffffff1681526020810191909152604001600020541492915050565b63ffffffff811660009081526001602052604081205480610891576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff8416600482015260240161072b565b60006117e68686612081565b805190915060005b8181101561189d57600083828151811061180a5761180a612c00565b60200260200101519050611821816000015161196b565b6001600160a01b0316639561b12f61183c60208e018e612ae8565b83602001516040518363ffffffff1660e01b815260040161185e9291906132c6565b600060405180830381600087803b15801561187857600080fd5b505af115801561188c573d6000803e3d6000fd5b5050600190930192506117ee915050565b50505050505050505050565b6000546001600160a01b03163314610b8b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161072b565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b9101610922565b61ffff81166000908152600460205260409020546001600160a01b0316806119bf576040517f8b6fecb700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b815160609060006119d760086004613335565b6119e49060ff168561334e565b6119f060026001613335565b6119fd9060ff168461334e565b611a08906001613365565b611a129190613365565b9050611a31604051806040016040528060608152602001600081525090565b611a3b818361230e565b50611a4f611a4884612385565b829061241c565b5060005b83811015611b2d576000878281518110611a6f57611a6f612c00565b60209081029190910101518051909150611a9090849061ffff166002612485565b50602081015151611aaa611aa382612385565b859061241c565b5060005b81811015611b2257600083602001518281518110611ace57611ace612c00565b60200260200101519050611afb816000015163ffffffff16600460ff16886124859092919063ffffffff16565b506020810151611b1890879067ffffffffffffffff166008612485565b5050600101611aae565b505050600101611a53565b505195945050505050565b6060600082611b468561250a565b611b509190613378565b63ffffffff85166000908152600660209081526040808320600384529091529020805491925090611b8090612b84565b80601f0160208091040260200160405190810160405280929190818152602001828054611bac90612b84565b8015611bf95780601f10611bce57610100808354040283529160200191611bf9565b820191906000526020600020905b815481529060010190602001808311611bdc57829003601f168201915b505050505091508151600014611c39578160016011600184604051602001611c259594939291906133a4565b604051602081830303815290604052610b9a565b6040517e0300000000000000000000000000000000000000000000000000000000000060208201527f0100000000000000000000000000000000000000000000000000000000000000602282018190527e11000000000000000000000000000000000000000000000000000000000000602383015260258201527fffffffffffffffffffffffffffffffff00000000000000000000000000000000608083901b166026820152603601604051602081830303815290604052949350505050565b611d016126bf565b6000611d10846000015161256c565b90507f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001611d628c611785565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401611d9e929190613455565b60806040518083038185885af1158015611dbc573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611de1919061351c565b979650505050505050565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60408051808201909152600080825260208201527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663ddc28c586040518060a001604052808863ffffffff168152602001611eb789611785565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b8152600401611eec929190613455565b6040805180830381865afa158015611f08573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f2c9190613566565b95945050505050565b60005b815181101561200c57611f67828281518110611f5657611f56612c00565b60200260200101516040015161203c565b818181518110611f7957611f79612c00565b60200260200101516040015160066000848481518110611f9b57611f9b612c00565b60200260200101516000015163ffffffff1663ffffffff1681526020019081526020016000206000848481518110611fd557611fd5612c00565b60200260200101516020015161ffff1661ffff168152602001908152602001600020908161200391906135cf565b50600101611f38565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b67481604051610c0c919061368f565b600281015161ffff81166003146107cf57816040517f9a6d49cd00000000000000000000000000000000000000000000000000000000815260040161072b91906128f3565b606060008383600081811061209857612098612c00565b919091013560f81c915081905067ffffffffffffffff8111156120bd576120bd612bd1565b60405190808252806020026020018201604052801561210357816020015b6040805180820190915260008152606060208201528152602001906001900390816120db5790505b509150600160005b8260ff168110156122cc576000868387612126600283613365565b955061213592869291906130a5565b61213e91613738565b60f01c9050600087878581811061215757612157612c00565b919091013560f81c915061216e9050600185613365565b935060008160ff1667ffffffffffffffff81111561218e5761218e612bd1565b6040519080825280602002602001820160405280156121d357816020015b60408051808201909152600080825260208201528152602001906001900390816121ac5790505b50905060005b8260ff1681101561228a5760008a878b6121f4600483613365565b9950612203928a9291906130a5565b61220c9161377e565b60e01c905060008b888c612221600883613365565b9a50612230928b9291906130a5565b612239916137c4565b60c01c905060405180604001604052808363ffffffff1681526020018267ffffffffffffffff1681525084848151811061227557612275612c00565b602090810291909101015250506001016121d9565b5060405180604001604052808461ffff168152602001828152508785815181106122b6576122b6612c00565b602090810291909101015250505060010161210b565b50808414612306576040517fa7272c6200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505092915050565b60408051808201909152606081526000602082015261232e60208361380a565b156123565761233e60208361380a565b612349906020613845565b6123539083613365565b91505b60208084018390526040518085526000815290818401018181101561237a57600080fd5b604052509192915050565b600060ff821115612418576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203860448201527f2062697473000000000000000000000000000000000000000000000000000000606482015260840161072b565b5090565b6040805180820190915260608152600060208201528251516000612441826001613365565b905084602001518210612462576124628561245d83600261334e565b6125a9565b845160208382010185815350805182111561247b578181525b5093949350505050565b60408051808201909152606081526000602082015283515160006124a98285613365565b905085602001518111156124c6576124c68661245d83600261334e565b600060016124d68661010061393c565b6124e09190613845565b905086518281018783198251161781525080518311156124fe578281525b50959695505050505050565b63ffffffff81166000908152600760205260408120546fffffffffffffffffffffffffffffffff16908190036119bf576040517fc960f36b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000813414612418576040517f9f70412000000000000000000000000000000000000000000000000000000000815234600482015260240161072b565b81516125b5838361230e565b506125c083826125c6565b50505050565b6040805180820190915260608152600060208201526125e7838384516125ee565b9392505050565b604080518082019091526060815260006020820152825182111561261157600080fd5b83515160006126208483613365565b9050856020015181111561263d5761263d8661245d83600261334e565b855180518382016020019160009180851115612657578482525b505050602086015b602086106126975780518252612676602083613365565b9150612683602082613365565b9050612690602087613845565b955061265f565b51815160001960208890036101000a0190811690199190911617905250849150509392505050565b604051806060016040528060008019168152602001600067ffffffffffffffff168152602001612702604051806040016040528060008152602001600081525090565b905290565b60006060828403121561271957600080fd5b50919050565b60008083601f84011261273157600080fd5b50813567ffffffffffffffff81111561274957600080fd5b60208301915083602082850101111561276157600080fd5b9250929050565b80356001600160a01b03811681146119bf57600080fd5b600080600080600080600060e0888a03121561279a57600080fd5b6127a48989612707565b965060608801359550608088013567ffffffffffffffff808211156127c857600080fd5b6127d48b838c0161271f565b90975095508591506127e860a08b01612768565b945060c08a01359150808211156127fe57600080fd5b5061280b8a828b0161271f565b989b979a50959850939692959293505050565b63ffffffff8116811461174c57600080fd5b6000806040838503121561284357600080fd5b823561284e8161281e565b946020939093013593505050565b803561ffff811681146119bf57600080fd5b6000806040838503121561288157600080fd5b823561288c8161281e565b915061289a6020840161285c565b90509250929050565b60005b838110156128be5781810151838201526020016128a6565b50506000910152565b600081518084526128df8160208601602086016128a3565b601f01601f19169290920160200192915050565b6020815260006125e760208301846128c7565b60006020828403121561291857600080fd5b6125e78261285c565b6000806040838503121561293457600080fd5b823561293f8161281e565b915060208301356fffffffffffffffffffffffffffffffff8116811461296457600080fd5b809150509250929050565b60008083601f84011261298157600080fd5b50813567ffffffffffffffff81111561299957600080fd5b6020830191508360208260051b850101111561276157600080fd5b6000806000604084860312156129c957600080fd5b83356129d48161281e565b9250602084013567ffffffffffffffff8111156129f057600080fd5b6129fc8682870161296f565b9497909650939450505050565b60008060008060a08587031215612a1f57600080fd5b612a298686612707565b9350606085013567ffffffffffffffff811115612a4557600080fd5b612a518782880161271f565b9094509250612a64905060808601612768565b905092959194509250565b600060208284031215612a8157600080fd5b6125e782612768565b60008060408385031215612a9d57600080fd5b61288c83612768565b60008060208385031215612ab957600080fd5b823567ffffffffffffffff811115612ad057600080fd5b612adc8582860161296f565b90969095509350505050565b600060208284031215612afa57600080fd5b81356125e78161281e565b60008060008060608587031215612b1b57600080fd5b8435612b268161281e565b9350612b346020860161285c565b9250604085013567ffffffffffffffff811115612b5057600080fd5b612b5c8782880161271f565b95989497509550505050565b600060608284031215612b7a57600080fd5b6125e78383612707565b600181811c90821680612b9857607f821691505b602082108103612719577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112612c6357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612ca257600080fd5b83018035915067ffffffffffffffff821115612cbd57600080fd5b602001915060608102360382131561276157600080fd5b67ffffffffffffffff8116811461174c57600080fd5b63ffffffff84811682526040602080840182905283820185905260009260609182860188865b89811015612d67578135612d238161281e565b8516835281840135612d3481612cd4565b67ffffffffffffffff908116848601528288013590612d5282612cd4565b16838801529185019190850190600101612d10565b50909a9950505050505050505050565b6040805190810167ffffffffffffffff81118282101715612d9a57612d9a612bd1565b60405290565b6040516060810167ffffffffffffffff81118282101715612d9a57612d9a612bd1565b604051601f8201601f1916810167ffffffffffffffff81118282101715612dec57612dec612bd1565b604052919050565b600067ffffffffffffffff821115612e0e57612e0e612bd1565b5060051b60200190565b60006020808385031215612e2b57600080fd5b825167ffffffffffffffff811115612e4257600080fd5b8301601f81018513612e5357600080fd5b8051612e66612e6182612df4565b612dc3565b81815260069190911b82018301908381019087831115612e8557600080fd5b928401925b82841015611de15760408489031215612ea35760008081fd5b612eab612d77565b8451612eb68161281e565b815284860151612ec581612cd4565b8187015282526040939093019290840190612e8a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006000198203612f1d57612f1d612edb565b5060010190565b6fffffffffffffffffffffffffffffffff818116838216019080821115612f4d57612f4d612edb565b5092915050565b600060208284031215612f6657600080fd5b81356125e781612cd4565b600067ffffffffffffffff821115612f8b57612f8b612bd1565b50601f01601f191660200190565b6000612fa7612e6184612df4565b80848252602080830192508560051b850136811115612fc557600080fd5b855b8181101561309957803567ffffffffffffffff80821115612fe85760008081fd5b818901915060608236031215612ffe5760008081fd5b613006612da0565b82356130118161281e565b815261301e83870161285c565b86820152604080840135838111156130365760008081fd5b939093019236601f85011261304d57600092508283fd5b8335925061305d612e6184612f71565b83815236888587010111156130725760008081fd5b83888601898301376000938101880193909352810191909152865250938201938201612fc7565b50919695505050505050565b600080858511156130b557600080fd5b838611156130c257600080fd5b5050820193919092039150565b600084516130e18184602089016128a3565b8201838582376000930192835250909392505050565b818352818160208501375060006020828401015260006020601f19601f840116840101905092915050565b602081526000610b9a6020830184866130f7565b600082357ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec1833603018112612c6357600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261319f57600080fd5b83018035915067ffffffffffffffff8211156131ba57600080fd5b60200191503681900382131561276157600080fd5b600088356131dc8161281e565b63ffffffff1682526020898101359083015260408901356131fc81612cd4565b67ffffffffffffffff811660408401525087606083015260e0608083015261322860e0830187896130f7565b6001600160a01b03861660a084015282810360c084015261324a8185876130f7565b9a9950505050505050505050565b60006020828403121561326a57600080fd5b815167ffffffffffffffff81111561328157600080fd5b8201601f8101841361329257600080fd5b80516132a0612e6182612f71565b8181528560208385010111156132b557600080fd5b611f2c8260208301602086016128a3565b6000604080830163ffffffff808716855260206040602087015282875180855260608801915060208901945060005b8181101561332657855180518616845284015167ffffffffffffffff168484015294830194918601916001016132f5565b50909998505050505050505050565b60ff818116838216019081111561089157610891612edb565b808202811582820484141761089157610891612edb565b8082018082111561089157610891612edb565b6fffffffffffffffffffffffffffffffff81811683821602808216919082811461230657612306612edb565b600086516133b6818460208b016128a3565b60f896871b7fff000000000000000000000000000000000000000000000000000000000000009081169390910192835260f09590951b7fffff000000000000000000000000000000000000000000000000000000000000166001830152509190931b909116600382015260809190911b7fffffffffffffffffffffffffffffffff00000000000000000000000000000000166004820152601401919050565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a0608084015261348b60e08401826128c7565b905060608501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08483030160a08501526134c682826128c7565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b6000604082840312156134fe57600080fd5b613506612d77565b9050815181526020820151602082015292915050565b60006080828403121561352e57600080fd5b613536612da0565b82518152602083015161354881612cd4565b602082015261355a84604085016134ec565b60408201529392505050565b60006040828403121561357857600080fd5b6125e783836134ec565b601f8211156135ca576000816000526020600020601f850160051c810160208610156135ab5750805b601f850160051c820191505b81811015610b71578281556001016135b7565b505050565b815167ffffffffffffffff8111156135e9576135e9612bd1565b6135fd816135f78454612b84565b84613582565b602080601f831160018114613632576000841561361a5750858301515b600019600386901b1c1916600185901b178555610b71565b600085815260208120601f198616915b8281101561366157888601518255948401946001909101908401613642565b508582101561367f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083018184528085518083526040925060408601915060408160051b87010184880160005b8381101561372a578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc00185528151805163ffffffff1684528781015161ffff16888501528601516060878501819052613716818601836128c7565b9689019694505050908601906001016136b8565b509098975050505050505050565b7fffff00000000000000000000000000000000000000000000000000000000000081358181169160028510156123065760029490940360031b84901b1690921692915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081358181169160048510156123065760049490940360031b84901b1690921692915050565b7fffffffffffffffff00000000000000000000000000000000000000000000000081358181169160088510156123065760089490940360031b84901b1690921692915050565b600082613840577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b8181038181111561089157610891612edb565b600181815b8085111561389357816000190482111561387957613879612edb565b8085161561388657918102915b93841c939080029061385d565b509250929050565b6000826138aa57506001610891565b816138b757506000610891565b81600181146138cd57600281146138d7576138f3565b6001915050610891565b60ff8411156138e8576138e8612edb565b50506001821b610891565b5060208310610133831016604e8410600b8410161715613916575081810a610891565b6139208383613858565b806000190482111561393457613934612edb565b029392505050565b60006125e7838361389b56fea2646970667358221220626c4561e4bc699b85f4a1ad821a89d68653b23e8fd1f94604840d7d4e69f49c64736f6c63430008160033

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

0000000000000000000000001a44076050125825900e736c501f859c50fe728c0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc24

-----Decoded View---------------
Arg [0] : _endpoint (address): 0x1a44076050125825900e736c501f859c50fE728c
Arg [1] : _owner (address): 0x4A79AdC4539905376D339C69b6a7092D0598cc24

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000001a44076050125825900e736c501f859c50fe728c
Arg [1] : 0000000000000000000000004a79adc4539905376d339c69b6a7092d0598cc24


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ 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.