Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00Multichain Info
N/A
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 15629719 | 39 hrs ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
AgoraMintBurnOFTAdapter
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 100000000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;
import { PausableUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { Origin } from "@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppUpgradeable.sol";
import { OFTAdapterUpgradeable } from "@layerzerolabs/oft-evm-upgradeable/contracts/oft/OFTAdapterUpgradeable.sol";
import { IMintableBurnable } from "@layerzerolabs/oft-evm/contracts/interfaces/IMintableBurnable.sol";
import { OFTMsgCodec } from "@layerzerolabs/oft-evm/contracts/libs/OFTMsgCodec.sol";
import { Erc1967Implementation } from "agora-contracts/proxy/Erc1967Implementation.sol";
import { AgoraOFTAdapterAccessControl } from "./AgoraOFTAdapterAccessControl.sol";
import { AgoraRateLimiter } from "./AgoraRateLimiter.sol";
/// @title AgoraMintBurnOFTAdapter Contract
/// @notice AgoraMintBurnOFTAdapter is a contract that adapts an ERC-20 token
/// with external mint and burn logic to the OFT functionality.
contract AgoraMintBurnOFTAdapter is
OFTAdapterUpgradeable,
AgoraOFTAdapterAccessControl,
AgoraRateLimiter,
PausableUpgradeable,
Erc1967Implementation
{
using OFTMsgCodec for bytes;
using OFTMsgCodec for bytes32;
/// @notice Constructor for the AgoraMintBurnOFTAdapter contract.
/// @param _token The address of the ERC-20 token to be bridged.
/// @param _lzEndpoint The LayerZero endpoint address.
/// @dev _token must implement both IERC20 interface, and the
/// IMintableBurnable interfaces, and include a decimals() function.
constructor(address _token, address _lzEndpoint) OFTAdapterUpgradeable(_token, _lzEndpoint) {
_disableInitializers();
}
/// @notice Initializes the AgoraMintBurnOFTAdapter with the provided params.
/// @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
/// @param _initialOwner The initial contract owner.
/// @param _initialAccessControlManager The initial contract access control manager.
/// @param _initialPauser The initial contract pauser.
/// @param _initialRateLimitManager The initial contract rate limit manager.
/// @dev The delegate typically should be set as the owner of the contract.
function initialize(
address _delegate,
address _initialOwner,
address _initialAccessControlManager,
address _initialPauser,
address _initialRateLimitManager
) public initializer {
__Ownable_init(_initialOwner);
__AgoraOFTAdapterAccessControl_init({
_initialAdminAddress: _initialAccessControlManager,
_initialPauser: _initialPauser,
_initialRateLimitManager: _initialRateLimitManager
});
__Pausable_init();
__OFTAdapter_init(_delegate);
}
//==============================================================================
// Pausable Overrides
//==============================================================================
/// @notice Pauses outbound bridging.
/// @dev Must be called by an address holding `PAUSER_ROLE`
function pause() external {
/// Check: Must be called by an address holding `PAUSER_ROLE`
_requireSenderIsRole(PAUSER_ROLE);
/// Effect: Pause the contract.
_pause();
}
/// @notice Unpauses outbound bridging.
/// @dev Must be called by an address holding `PAUSER_ROLE`
function unpause() external {
/// Check: Must be called by an address holding `PAUSER_ROLE`
_requireSenderIsRole(PAUSER_ROLE);
/// Effect: Unpause the contract.
_unpause();
}
//==============================================================================
// MintBurnOFTAdapter Overrides
//==============================================================================
/// @notice Indicates whether the OFT contract requires approval of the underlying token to send.
/// @return requiresApproval True if approval is required, false otherwise.
/// @dev In this MintBurnOFTAdapter, approval is NOT required because it uses mint and burn privileges.
function approvalRequired() external pure override returns (bool) {
return false;
}
/// @notice Checks and updates the rate limit before initiating a token transfer.
/// @param _amountLocalDecimals The amount of tokens to be transferred.
/// @param _minAmountLocalDecimals The minimum amount of tokens expected to be received.
/// @param _destinationEndpointId The destination endpoint identifier.
/// @return amountSentLocalDecimals The actual amount of tokens sent.
/// @return amountReceivedLocalDecimals The actual amount of tokens received.
/// @dev Will revert if the contract is paused or if the rate limit is exceeded.
function _debit(
address _from,
uint256 _amountLocalDecimals,
uint256 _minAmountLocalDecimals,
uint32 _destinationEndpointId
) internal virtual override returns (uint256 amountSentLocalDecimals, uint256 amountReceivedLocalDecimals) {
/// Check: Don't allow outbound bridging if the contract is paused.
_requireNotPaused();
/// Check: Enforce the rate limit for outbound transfers.
_rateLimitOutflow({ _from: _from, _amountLocalDecimals: _amountLocalDecimals });
(amountSentLocalDecimals, amountReceivedLocalDecimals) = _debitView(
_amountLocalDecimals,
_minAmountLocalDecimals,
_destinationEndpointId
);
/// Check: Don't allow zero amount sends to prevent spam. This should /
/// also be caught by the token, but doesn't hurt to double check.
if (amountSentLocalDecimals == 0) revert ZeroAmount();
if (amountReceivedLocalDecimals == 0) revert ZeroAmount();
// Burns tokens from the caller.
bool _burnSuccess = IMintableBurnable(address(innerToken)).burn(_from, amountSentLocalDecimals);
if (!_burnSuccess) {
revert BurnFailed();
}
return (amountSentLocalDecimals, amountReceivedLocalDecimals);
}
/// @notice Mints tokens to the specified address upon receiving them.
/// @param _to The address to credit the tokens to.
/// @param _amountLocalDecimals The amount of tokens to credit in local decimals.
/// @return amountReceivedLocalDecimals The amount of tokens actually received in local decimals.
/// @dev If the `_to` address is `address(0x0)`, the tokens are minted to `address(0xdead)`.
/// @dev Will revert if the contract is paused or if the rate limit is exceeded.
function _credit(
address _to,
uint256 _amountLocalDecimals,
uint32 // _sourceEndpointId
) internal virtual override returns (uint256 amountReceivedLocalDecimals) {
/// Check: Don't allow inbound bridging if the contract is paused.
_requireNotPaused();
if (_to == address(0x0)) _to = address(0xdead); // _mint(...) does not support address(0x0)
// Mints the tokens and transfers to the recipient.
bool _mintSuccess = IMintableBurnable(address(innerToken)).mint(_to, _amountLocalDecimals);
if (!_mintSuccess) {
revert MintFailed();
}
// In the case of NON-default OFTAdapter, the amountLocalDecimals MIGHT
// not be equal to amountReceivedLocalDecimals.
return _amountLocalDecimals;
}
/// @notice Override the base _lzReceive() function to use _rateLimitInflow() before super._lzReceive()
/// @dev This function is called when a message is received from another chain.
/// @param _origin The origin of the message.
/// @param _guid The GUID of the message.
/// @param _message The message data.
/// @param _executor The address of the executor.
/// @param _extraData Additional data for the message.
function _lzReceive(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address _executor, // @dev unused in the default implementation.
bytes calldata _extraData // @dev unused in the default implementation.
) internal virtual override {
/// Check: Enforce the rate limit for inbound transfers.
address _to = _message.sendTo().bytes32ToAddress();
_rateLimitInflow({ _messageGuid: _guid, _to: _to, _amountLocalDecimals: _toLD(_message.amountSD()) });
/// Effect: Call the parent _lzReceive function to handle the message.
super._lzReceive(_origin, _guid, _message, _executor, _extraData);
}
//==============================================================================
// Version Functions
//==============================================================================
/// @notice The ```Version``` struct is used to represent the version of the AgoraMintBurnOFTAdapter
/// @param major The major version number
/// @param minor The minor version number
/// @param patch The patch version number
struct Version {
uint256 major;
uint256 minor;
uint256 patch;
}
/// @notice The ```version``` function returns the version of the AgoraMintBurnOFTAdapter
/// @return _version The version of the AgoraMintBurnOFTAdapter
function version() public pure returns (Version memory _version) {
_version = Version({ major: 1, minor: 0, patch: 0 });
}
//==============================================================================
// Errors
//==============================================================================
error BurnFailed();
error MintFailed();
error ZeroAmount();
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
function __Pausable_init() internal onlyInitializing {
}
function __Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// 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 { OAppSenderUpgradeable, MessagingFee, MessagingReceipt } from "./OAppSenderUpgradeable.sol";
// @dev Import the 'Origin' so it's exposed to OApp implementers
// solhint-disable-next-line no-unused-import
import { OAppReceiverUpgradeable, Origin } from "./OAppReceiverUpgradeable.sol";
import { OAppCoreUpgradeable } from "./OAppCoreUpgradeable.sol";
/**
* @title OApp
* @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.
*/
abstract contract OAppUpgradeable is OAppSenderUpgradeable, OAppReceiverUpgradeable {
/**
* @dev Constructor to initialize the OApp with the provided endpoint and owner.
* @param _endpoint The address of the LOCAL LayerZero endpoint.
*/
constructor(address _endpoint) OAppCoreUpgradeable(_endpoint) {}
/**
* @dev Initializes the OApp with the provided delegate.
* @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.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OApp_init(address _delegate) internal onlyInitializing {
__OAppCore_init(_delegate);
__OAppReceiver_init_unchained();
__OAppSender_init_unchained();
}
function __OApp_init_unchained() internal onlyInitializing {}
/**
* @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(OAppSenderUpgradeable, OAppReceiverUpgradeable)
returns (uint64 senderVersion, uint64 receiverVersion)
{
return (SENDER_VERSION, RECEIVER_VERSION);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { IERC20Metadata, IERC20 } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { IOFT, OFTCoreUpgradeable } from "./OFTCoreUpgradeable.sol";
/**
* @title OFTAdapter Contract
* @dev OFTAdapter is a contract that adapts an ERC-20 token to the OFT functionality.
*
* @dev For existing ERC20 tokens, this can be used to convert the token to crosschain compatibility.
* @dev WARNING: ONLY 1 of these should exist for a given global mesh,
* unless you make a NON-default implementation of OFT and needs to be done very carefully.
* @dev WARNING: The default OFTAdapter implementation assumes LOSSLESS transfers, ie. 1 token in, 1 token out.
* IF the 'innerToken' applies something like a transfer fee, the default will NOT work...
* a pre/post balance check will need to be done to calculate the amountSentLD/amountReceivedLD.
*/
abstract contract OFTAdapterUpgradeable is OFTCoreUpgradeable {
using SafeERC20 for IERC20;
IERC20 internal immutable innerToken;
/**
* @dev Constructor for the OFTAdapter contract.
* @param _token The address of the ERC-20 token to be adapted.
* @param _lzEndpoint The LayerZero endpoint address.
* @dev _token must implement the IERC20 interface, and include a decimals() function.
*/
constructor(
address _token,
address _lzEndpoint
) OFTCoreUpgradeable(IERC20Metadata(_token).decimals(), _lzEndpoint) {
innerToken = IERC20(_token);
}
/**
* @dev Initializes the OFTAdapter with the provided delegate.
* @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.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OFTAdapter_init(address _delegate) internal onlyInitializing {
__OFTCore_init(_delegate);
}
function __OFTAdapter_init_unchained() internal onlyInitializing {}
/**
* @dev Retrieves the address of the underlying ERC20 implementation.
* @return The address of the adapted ERC-20 token.
*
* @dev In the case of OFTAdapter, address(this) and erc20 are NOT the same contract.
*/
function token() public view returns (address) {
return address(innerToken);
}
/**
* @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev In the case of default OFTAdapter, approval is required.
* @dev In non-default OFTAdapter contracts with something like mint and burn privileges, it would NOT need approval.
*/
function approvalRequired() external pure virtual returns (bool) {
return true;
}
/**
* @dev Burns tokens from the sender's specified balance, ie. pull method.
* @param _from The address to debit from.
* @param _amountLD The amount of tokens to send in local decimals.
* @param _minAmountLD The minimum amount to send in local decimals.
* @param _dstEid The destination chain ID.
* @return amountSentLD The amount sent in local decimals.
* @return amountReceivedLD The amount received in local decimals on the remote.
*
* @dev msg.sender will need to approve this _amountLD of tokens to be locked inside of the contract.
* @dev WARNING: The default OFTAdapter implementation assumes LOSSLESS transfers, ie. 1 token in, 1 token out.
* IF the 'innerToken' applies something like a transfer fee, the default will NOT work...
* a pre/post balance check will need to be done to calculate the amountReceivedLD.
*/
function _debit(
address _from,
uint256 _amountLD,
uint256 _minAmountLD,
uint32 _dstEid
) internal virtual override returns (uint256 amountSentLD, uint256 amountReceivedLD) {
(amountSentLD, amountReceivedLD) = _debitView(_amountLD, _minAmountLD, _dstEid);
// @dev Lock tokens by moving them into this contract from the caller.
innerToken.safeTransferFrom(_from, address(this), amountSentLD);
}
/**
* @dev Credits tokens to the specified address.
* @param _to The address to credit the tokens to.
* @param _amountLD The amount of tokens to credit in local decimals.
* @dev _srcEid The source chain ID.
* @return amountReceivedLD The amount of tokens ACTUALLY received in local decimals.
*
* @dev WARNING: The default OFTAdapter implementation assumes LOSSLESS transfers, ie. 1 token in, 1 token out.
* IF the 'innerToken' applies something like a transfer fee, the default will NOT work...
* a pre/post balance check will need to be done to calculate the amountReceivedLD.
*/
function _credit(
address _to,
uint256 _amountLD,
uint32 /*_srcEid*/
) internal virtual override returns (uint256 amountReceivedLD) {
// @dev Unlock the tokens and transfer to the recipient.
innerToken.safeTransfer(_to, _amountLD);
// @dev In the case of NON-default OFTAdapter, the amountLD MIGHT not be == amountReceivedLD.
return _amountLD;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
/// @title Interface for mintable and burnable tokens
interface IMintableBurnable {
/**
* @notice Burns tokens from a specified account
* @param _from Address from which tokens will be burned
* @param _amount Amount of tokens to be burned
* @return success Indicates whether the operation was successful
*/
function burn(address _from, uint256 _amount) external returns (bool success);
/**
* @notice Mints tokens to a specified account
* @param _to Address to which tokens will be minted
* @param _amount Amount of tokens to be minted
* @return success Indicates whether the operation was successful
*/
function mint(address _to, uint256 _amount) external returns (bool success);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library OFTMsgCodec {
// Offset constants for encoding and decoding OFT messages
uint8 private constant SEND_TO_OFFSET = 32;
uint8 private constant SEND_AMOUNT_SD_OFFSET = 40;
/**
* @dev Encodes an OFT LayerZero message.
* @param _sendTo The recipient address.
* @param _amountShared The amount in shared decimals.
* @param _composeMsg The composed message.
* @return _msg The encoded message.
* @return hasCompose A boolean indicating whether the message has a composed payload.
*/
function encode(
bytes32 _sendTo,
uint64 _amountShared,
bytes memory _composeMsg
) internal view returns (bytes memory _msg, bool hasCompose) {
hasCompose = _composeMsg.length > 0;
// @dev Remote chains will want to know the composed function caller ie. msg.sender on the src.
_msg = hasCompose
? abi.encodePacked(_sendTo, _amountShared, addressToBytes32(msg.sender), _composeMsg)
: abi.encodePacked(_sendTo, _amountShared);
}
/**
* @dev Checks if the OFT message is composed.
* @param _msg The OFT message.
* @return A boolean indicating whether the message is composed.
*/
function isComposed(bytes calldata _msg) internal pure returns (bool) {
return _msg.length > SEND_AMOUNT_SD_OFFSET;
}
/**
* @dev Retrieves the recipient address from the OFT message.
* @param _msg The OFT message.
* @return The recipient address.
*/
function sendTo(bytes calldata _msg) internal pure returns (bytes32) {
return bytes32(_msg[:SEND_TO_OFFSET]);
}
/**
* @dev Retrieves the amount in shared decimals from the OFT message.
* @param _msg The OFT message.
* @return The amount in shared decimals.
*/
function amountSD(bytes calldata _msg) internal pure returns (uint64) {
return uint64(bytes8(_msg[SEND_TO_OFFSET:SEND_AMOUNT_SD_OFFSET]));
}
/**
* @dev Retrieves the composed message from the OFT message.
* @param _msg The OFT message.
* @return The composed message.
*/
function composeMsg(bytes calldata _msg) internal pure returns (bytes memory) {
return _msg[SEND_AMOUNT_SD_OFFSET:];
}
/**
* @dev Converts an address to bytes32.
* @param _addr The address to convert.
* @return The bytes32 representation of the address.
*/
function addressToBytes32(address _addr) internal pure returns (bytes32) {
return bytes32(uint256(uint160(_addr)));
}
/**
* @dev Converts bytes32 to an address.
* @param _b The bytes32 value to convert.
* @return The address representation of bytes32.
*/
function bytes32ToAddress(bytes32 _b) internal pure returns (address) {
return address(uint160(uint256(_b)));
}
}// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.8.0;
// ====================================================================
// _ ______ ___ _______ _
// / \ .' ___ | .' `.|_ __ \ / \
// / _ \ / .' \_| / .-. \ | |__) | / _ \
// / ___ \ | | ____ | | | | | __ / / ___ \
// _/ / \ \_\ `.___] |\ `-' /_| | \ \_ _/ / \ \_
// |____| |____|`._____.' `.___.'|____| |___||____| |____|
// ====================================================================
// ====================== Erc1967Implementation =======================
// ====================================================================
/// @title Erc1967Implementation
/// @notice The Erc1967Implementation is a contract that provides visibility into the Erc1967Implementation and its associated storage slots.
/// @author Agora
abstract contract Erc1967Implementation {
//==============================================================================
// Erc1967 Admin Slot Items
//==============================================================================
/// @notice The Erc1967ProxyAdminStorage struct
/// @param proxyAdminAddress The address of the proxy admin contract
/// @custom:storage-location erc1967:eip1967.proxy.admin
struct Erc1967ProxyAdminStorage {
address proxyAdminAddress;
}
/// @notice The ```ERC1967_PROXY_ADMIN_STORAGE_SLOT_``` is the storage slot for the Erc1967ProxyAdminStorage struct
/// @dev NOTE: deviates from erc7201 standard because erc1967 defines its own storage slot algorithm
/// @dev bytes32(uint256(keccak256("eip1967.proxy.admin")) - 1)
bytes32 internal constant ERC1967_PROXY_ADMIN_STORAGE_SLOT_ =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/// @notice The ```getPointerToErc1967ProxyAdminStorage``` function returns a pointer to the Erc1967ProxyAdminStorage struct
/// @return adminSlot A pointer to the Erc1967ProxyAdminStorage struct
function getPointerToErc1967ProxyAdminStorage() internal pure returns (Erc1967ProxyAdminStorage storage adminSlot) {
/// @solidity memory-safe-assembly
assembly {
adminSlot.slot := ERC1967_PROXY_ADMIN_STORAGE_SLOT_
}
}
/// @notice The ```proxyAdminAddress``` function returns the address of the proxy admin
/// @return The address of the proxy admin
function proxyAdminAddress() external view returns (address) {
return getPointerToErc1967ProxyAdminStorage().proxyAdminAddress;
}
//==============================================================================
// EIP1967 Proxy Implementation Slot Items
//==============================================================================
/// @notice The Erc1967ProxyContractStorage struct
/// @param implementationAddress The address of the implementation contract
/// @custom:storage-location erc1967:eip1967.proxy.implementation
struct Erc1967ProxyContractStorage {
address implementationAddress;
}
/// @notice The ```ERC1967_IMPLEMENTATION_CONTRACT_STORAGE_SLOT_``` is the storage slot for the implementation contract
/// @dev bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1)
bytes32 internal constant ERC1967_IMPLEMENTATION_CONTRACT_STORAGE_SLOT_ =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/// @notice The ```getPointerToImplementationStorage``` function returns a pointer to the Erc1967ProxyContractStorage struct
/// @return implementationSlot A pointer to the Erc1967ProxyContractStorage struct
function getPointerToImplementationStorage()
internal
pure
returns (Erc1967ProxyContractStorage storage implementationSlot)
{
/// @solidity memory-safe-assembly
assembly {
implementationSlot.slot := ERC1967_IMPLEMENTATION_CONTRACT_STORAGE_SLOT_
}
}
/// @notice The ```implementationAddress``` function returns the address of the implementation contract
/// @return The address of the implementation contract
function implementationAddress() external view returns (address) {
return getPointerToImplementationStorage().implementationAddress;
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { AgoraAccessControl } from "agora-contracts/access-control/AgoraAccessControl.sol";
/// @title AgoraOFTAdapterAccessControl Contract
/// @notice AgoraOFTAdapterAccessControl initializes and manages the access
/// control roles specific to the AgoraMintBurnOFTAdapter.
abstract contract AgoraOFTAdapterAccessControl is AgoraAccessControl, Initializable {
string public constant PAUSER_ROLE = "PAUSER_ROLE";
string public constant RATE_LIMIT_EXEMPT_ROLE = "RATE_LIMIT_EXEMPT_ROLE";
string public constant RATE_LIMIT_MANAGER_ROLE = "RATE_LIMIT_MANAGER_ROLE";
/// @notice Initializer for the `AgoraOFTAdapterAccessControl` contract
/// @param _initialAdminAddress The initial address to be granted `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _initialPauser The initial address to be granted `PAUSER_ROLE`
/// @param _initialRateLimitManager The initial address to be granted `RATE_LIMIT_MANAGER_ROLE`
/// @dev This function is called by the initializer of the inheriting contract
function __AgoraOFTAdapterAccessControl_init(
address _initialAdminAddress,
address _initialPauser,
address _initialRateLimitManager
) internal onlyInitializing {
/// Initialize the ACCESS_CONTROL_MANAGER_ROLE
_initializeAgoraAccessControl({ _initialAdminAddress: _initialAdminAddress });
/// Initialize the PAUSER_ROLE
_addRoleToSet({ _role: PAUSER_ROLE });
_assignRole({ _role: PAUSER_ROLE, _member: _initialPauser, _addRole: true });
/// Initialize the RATE_LIMIT_EXEMPT_ROLE
/// Note: No initial members
_addRoleToSet({ _role: RATE_LIMIT_EXEMPT_ROLE });
/// Initialize the RATE_LIMIT_MANAGER_ROLE
_addRoleToSet({ _role: RATE_LIMIT_MANAGER_ROLE });
_assignRole({ _role: RATE_LIMIT_MANAGER_ROLE, _member: _initialRateLimitManager, _addRole: true });
}
/// @notice Grants `PAUSER_ROLE` to an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _member The address to be granted the role
function grantPauserRole(address _member) public {
/// Checks: Only `ACCESS_CONTROL_MANAGER_ROLE` can grant the role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
/// Effects: set the role for the address
_assignRole({ _role: PAUSER_ROLE, _member: _member, _addRole: true });
}
/// @notice Revokes `PAUSER_ROLE` from an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _member The address to be revoked the role
function revokePauserRole(address _member) public {
/// Checks: Only `ACCESS_CONTROL_MANAGER_ROLE` can revoke the role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
/// Effects: remove the role for the address
_assignRole({ _role: PAUSER_ROLE, _member: _member, _addRole: false });
}
/// @notice Grants `RATE_LIMIT_MANAGER_ROLE` to an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _member The address to be granted the role
function grantRateLimitManagerRole(address _member) public {
// Checks: Only Admin can transfer role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
_assignRole({ _role: RATE_LIMIT_MANAGER_ROLE, _member: _member, _addRole: true });
}
/// @notice Revokes `RATE_LIMIT_MANAGER_ROLE` from an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _member The address to be revoked the role
function revokeRateLimitManagerRole(address _member) public {
/// Checks: Only `ACCESS_CONTROL_MANAGER_ROLE` can revoke the role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
_assignRole({ _role: RATE_LIMIT_MANAGER_ROLE, _member: _member, _addRole: false });
}
/// @notice Grants `RATE_LIMIT_EXEMPT_ROLE` to a set of addresses
/// @dev Must be called by an address holding `RATE_LIMIT_MANAGER_ROLE`
/// @param _members The addresses to be granted the role
function batchGrantRateLimitExemptRole(address[] memory _members) public {
/// Checks: Only the `RATE_LIMIT_MANAGER_ROLE` can grant the role
_requireSenderIsRole({ _role: RATE_LIMIT_MANAGER_ROLE });
/// Effects: set the role for the addresses
for (uint256 _i; _i < _members.length; ++_i) {
// Effects: set the role for the addresses
_assignRole({ _role: RATE_LIMIT_EXEMPT_ROLE, _member: _members[_i], _addRole: true });
}
}
/// @notice Revokes `RATE_LIMIT_EXEMPT_ROLE` from a set of addresses
/// @dev Must be called by an address holding `RATE_LIMIT_MANAGER_ROLE`
/// @param _members The addresses to be revoked the role
function batchRevokeRateLimitExemptRole(address[] memory _members) public {
/// Checks: Only the `RATE_LIMIT_MANAGER_ROLE` can revoke the role
_requireSenderIsRole({ _role: RATE_LIMIT_MANAGER_ROLE });
/// Effects: remove the role for the addresses
for (uint256 _i; _i < _members.length; ++_i) {
// Effects: set the role for the addresses
_assignRole({ _role: RATE_LIMIT_EXEMPT_ROLE, _member: _members[_i], _addRole: false });
}
}
//==============================================================================
// External View Functions
//==============================================================================
/// @notice Returns the addresses holding `PAUSER_ROLE`
/// @return The array of addresses holding `PAUSER_ROLE`
function getPauserRoleMembers() external view returns (address[] memory) {
return getRoleMembers(PAUSER_ROLE);
}
/// @notice Returns the addresses holding `RATE_LIMIT_MANAGER_ROLE`
/// @return The array of addresses holding `RATE_LIMIT_MANAGER_ROLE`
function getRateLimitManagerRoleMembers() external view returns (address[] memory) {
return getRoleMembers(RATE_LIMIT_MANAGER_ROLE);
}
/// @notice Returns the addresses holding `RATE_LIMIT_EXEMPT_ROLE`
/// @return The array of addresses holding `RATE_LIMIT_EXEMPT_ROLE`
function getRateLimitExemptRoleMembers() external view returns (address[] memory) {
return getRoleMembers(RATE_LIMIT_EXEMPT_ROLE);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.22;
import { AgoraOFTAdapterAccessControl } from "./AgoraOFTAdapterAccessControl.sol";
import { LZRateLimiterUpgradeable } from "./LZRateLimiterUpgradeable.sol";
/// @title AgoraRateLimiter Contract
/// @notice AgoraRateLimiter defines the rate limiting helpers, and exemption
/// rules for the AgoraMintBurnOFTAdapter contract.
/// @dev Note, unlike the default LZRateLimiterUpgradeable, this contract only
/// supports a single rate limit configuration, shared between all destinations.
abstract contract AgoraRateLimiter is LZRateLimiterUpgradeable, AgoraOFTAdapterAccessControl {
/// @notice Rate Limit Configuration struct.
/// @dev This is a simplified version of the LZRateLimiterUpgradeable's
/// for input/output, but it is converted and stored in the
/// LZRateLimiterUpgradeableStorage
/// @param limit This represents the maximum allowed amount within a given window.
/// @param window Defines the duration of the rate limiting window.
struct RateLimitConfig {
uint256 limit;
uint256 window;
}
/// @notice The AgoraRateLimiterStorage struct
/// @param exemptGuids Mapping from message ids, to if that message is exempt from rate limiting.
/// @custom:storage-location erc7201:AgoraRateLimiter.AgoraRateLimiterStorage
struct AgoraRateLimiterStorage {
mapping(bytes32 guid => bool isExempt) exemptGuids;
}
//==============================================================================
// Erc 7201: UnstructuredNamespace Storage Functions
//==============================================================================
/// @notice The storage slot for the AgoraRateLimiterStorage struct
/// @dev keccak256(abi.encode(uint256(keccak256("AgoraRateLimiter.AgoraRateLimiterStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 public constant AGORA_RATE_LIMITER_STORAGE_SLOT =
0x46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc000;
/// @notice Returns a pointer to the RateLimiterStorage struct
/// @return $ A pointer to the RateLimiterStorage struct
function _getPointerToAgoraRateLimiterStorage() internal pure returns (AgoraRateLimiterStorage storage $) {
/// @solidity memory-safe-assembly
//slither-disable-next-line assembly
assembly {
$.slot := AGORA_RATE_LIMITER_STORAGE_SLOT
}
}
//==============================================================================
// Config Setters
//==============================================================================
/// @notice Sets the rate limits based on RateLimitConfig array.
/// @dev Must be called by an address holding `RATE_LIMIT_MANAGER_ROLE`
/// @dev To disable rate limiting, either set `window=0`, or set `limit=type(uint256).max`
/// @dev These values are stored in the inherited LZRateLimiterUpgradeableStorage
/// @param _outbound A RateLimitConfig structure defining the rate limits for outbound transfers.
/// @param _inbound A RateLimitConfig structure defining the rate limits for inbound transfers.
function setRateLimits(RateLimitConfig calldata _outbound, RateLimitConfig calldata _inbound) external {
/// Checks: Only `RATE_LIMIT_MANAGER_ROLE` can set the rate limits
_requireSenderIsRole(RATE_LIMIT_MANAGER_ROLE);
/// Effects: Set the rate limits
LZRateLimitConfig[] memory _configs = new LZRateLimitConfig[](2);
_configs[0] = LZRateLimitConfig({ dstEid: 0, limit: _outbound.limit, window: _outbound.window });
_configs[1] = LZRateLimitConfig({ dstEid: 1, limit: _inbound.limit, window: _inbound.window });
_setRateLimits(_configs);
}
//==============================================================================
// Config Getters
//==============================================================================
/// @notice Gets the current rate limit configs for this network.
/// @return _outboundRateLimit The rate limit config for outbound flows.
/// @return _inboundRateLimit The rate limit config for inbound flows.
function getRateLimits()
external
view
returns (RateLimitConfig memory _outboundRateLimit, RateLimitConfig memory _inboundRateLimit)
{
RateLimit memory _outbound = _getPointerToLZRateLimiterStorage().rateLimits[0];
RateLimit memory _inbound = _getPointerToLZRateLimiterStorage().rateLimits[1];
_outboundRateLimit = RateLimitConfig({ limit: _outbound.limit, window: _outbound.window });
_inboundRateLimit = RateLimitConfig({ limit: _inbound.limit, window: _inbound.window });
return (_outboundRateLimit, _inboundRateLimit);
}
//==============================================================================
// Message Exemption Logic
//==============================================================================
/// @notice Modifies the rate-limit-exempt GUIDs in bulk.
/// @dev Must be called by an address holding `RATE_LIMIT_MANAGER_ROLE`
/// @dev This function allows the owner to set multiple GUIDs as overridable or not overridable.
/// @dev This is used when a message with a normal recipient has failed
/// due to rate limiting. This allows the owner to override the rate limit
/// for that GUID and that tx can be re-executed at the endpoint.
/// @param _guids The message GUIDs to modify.
/// @param _isExempt is applied to all GUIDs in the array.
function setRateLimitExemptGuids(bytes32[] calldata _guids, bool _isExempt) external {
/// Checks: Only `RATE_LIMIT_MANAGER_ROLE` can set the rate limits
_requireSenderIsRole(RATE_LIMIT_MANAGER_ROLE);
/// Effects: Set the GUID overrides
for (uint256 _i; _i < _guids.length; ++_i) {
_getPointerToAgoraRateLimiterStorage().exemptGuids[_guids[_i]] = _isExempt;
}
emit RateLimiterGUIDExemption(_guids, _isExempt);
}
/// @notice Checks if a message GUID is exempt from rate limiting.
/// @param _guid The message GUID to check.
/// @return _isExempt True if the GUID is exempt from rate limiting, false otherwise.
function isRateLimitExemptGuid(bytes32 _guid) public view returns (bool _isExempt) {
return _getPointerToAgoraRateLimiterStorage().exemptGuids[_guid];
}
//==============================================================================
// Rate Limiting Logic
//==============================================================================
/// @notice Records an outflow for rate limiting purposes. Will throw if the
/// outflow exceeds the rate limit, and the sender is not exempt.
/// @dev I've renamed this from `LZRateLimiterUpgradeable._outflow` because
/// this takes different arguments, and I don't want to confuse the two.
/// @param _from The address initiating the outflow.
/// @param _amountLocalDecimals The amount of the outflow.
function _rateLimitOutflow(address _from, uint256 _amountLocalDecimals) internal virtual {
/// Check: Is the sender exempt from rate limiting?
if (_isRole({ _role: RATE_LIMIT_EXEMPT_ROLE, _member: _from })) return;
/// Effect: Record the outflow
_outflow({ _dstEid: 0, _amount: _amountLocalDecimals });
}
/// @notice Records an inflow for rate limiting purposes. Will throw if the
/// inflow exceeds the rate limit, and the sender is not exempt.
/// @dev This is different from the LZRateLimiterUpgradeable._inflow
/// because, that subtracts from the inflight, and we actually want to track
/// and limit the inflows separately from the outflows.
/// @param _messageGuid The unique identifier for the message being processed.
/// @param _to The address initiating the inflow.
/// @param _amountLocalDecimals The amount of the inflow.
function _rateLimitInflow(bytes32 _messageGuid, address _to, uint256 _amountLocalDecimals) internal virtual {
/// Check: Is the sender exempt from rate limiting?
if (_isRole({ _role: RATE_LIMIT_EXEMPT_ROLE, _member: _to })) return;
/// Check: Is this message exempt from rate limiting?
if (isRateLimitExemptGuid(_messageGuid)) return;
/// Effect: Record the inflow. The LZRateLimiterUpgradeable tracks
//everything as an outflow, so we use outflow with dstEid=1 / to
//represent an inflow.
_outflow({ _dstEid: 1, _amount: _amountLocalDecimals });
}
//==============================================================================
// LZRateLimiterUpgradeable Overrides
//==============================================================================
/// @notice Get the current amount that can be sent to this destination
/// endpoint id for the given rate limit window.
/// @return currentAmountInFlight The current amount that was sent.
/// @return amountCanBeSent The amount that can be sent.
function getAmountCanBeSent() public view returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {
RateLimit memory rl = _getPointerToLZRateLimiterStorage().rateLimits[0];
return _amountCanBeSent(rl.amountInFlight, rl.lastUpdated, rl.limit, rl.window);
}
/// @notice Get the current amount that can be sent out from this chain for
/// the given rate limit window.
/// @dev The destination endpoint id is ignored, as this contract only
/// supports a single rate limit configuration.
/// @return currentAmountInFlight The current amount that was sent.
/// @return amountCanBeSent The amount that can be sent.
function getAmountCanBeSent(
uint32 // _dstEid
) public view override returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {
/// Ignore _dstEid. Only one rate limit config supported.
return getAmountCanBeSent();
}
/// @notice Get the current amount that can be received by this chain
/// @return currentAmountInFlight The current amount that was received.
/// @return amountCanBeReceived The amount that can be received.
function getAmountCanBeReceived() public view returns (uint256 currentAmountInFlight, uint256 amountCanBeReceived) {
RateLimit memory rl = _getPointerToLZRateLimiterStorage().rateLimits[1];
return _amountCanBeSent(rl.amountInFlight, rl.lastUpdated, rl.limit, rl.window);
}
//==============================================================================
// Events
//==============================================================================
event RateLimiterGUIDExemption(bytes32[] _guids, bool _isExempt);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}// 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 { OAppCoreUpgradeable } from "./OAppCoreUpgradeable.sol";
/**
* @title OAppSender
* @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.
*/
abstract contract OAppSenderUpgradeable is OAppCoreUpgradeable {
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;
/**
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppSender_init(address _delegate) internal onlyInitializing {
__OAppCore_init(_delegate);
}
function __OAppSender_init_unchained() internal onlyInitializing {}
/**
* @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);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { IOAppReceiver, Origin } from "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppReceiver.sol";
import { OAppCoreUpgradeable } from "./OAppCoreUpgradeable.sol";
/**
* @title OAppReceiver
* @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.
*/
abstract contract OAppReceiverUpgradeable is IOAppReceiver, OAppCoreUpgradeable {
// 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;
/**
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppReceiver_init(address _delegate) internal onlyInitializing {
__OAppCore_init(_delegate);
}
function __OAppReceiver_init_unchained() internal onlyInitializing {}
/**
* @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;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { IOAppCore, ILayerZeroEndpointV2 } from "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppCore.sol";
/**
* @title OAppCore
* @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.
*/
abstract contract OAppCoreUpgradeable is IOAppCore, OwnableUpgradeable {
struct OAppCoreStorage {
mapping(uint32 => bytes32) peers;
}
// keccak256(abi.encode(uint256(keccak256("layerzerov2.storage.oappcore")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OAPP_CORE_STORAGE_LOCATION =
0x72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f900;
function _getOAppCoreStorage() internal pure returns (OAppCoreStorage storage $) {
assembly {
$.slot := OAPP_CORE_STORAGE_LOCATION
}
}
// The LayerZero endpoint associated with the given OApp
ILayerZeroEndpointV2 public immutable endpoint;
/**
* @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.
* @param _endpoint The address of the LOCAL Layer Zero endpoint.
*/
constructor(address _endpoint) {
endpoint = ILayerZeroEndpointV2(_endpoint);
}
/**
* @dev Initializes the OAppCore with the provided delegate.
* @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.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppCore_init(address _delegate) internal onlyInitializing {
__OAppCore_init_unchained(_delegate);
}
function __OAppCore_init_unchained(address _delegate) internal onlyInitializing {
if (_delegate == address(0)) revert InvalidDelegate();
endpoint.setDelegate(_delegate);
}
/**
* @notice Returns the peer address (OApp instance) associated with a specific endpoint.
* @param _eid The endpoint ID.
* @return peer The address of the peer associated with the specified endpoint.
*/
function peers(uint32 _eid) public view override returns (bytes32) {
OAppCoreStorage storage $ = _getOAppCoreStorage();
return $.peers[_eid];
}
/**
* @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 {
OAppCoreStorage storage $ = _getOAppCoreStorage();
$.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) {
OAppCoreStorage storage $ = _getOAppCoreStorage();
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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity >=0.6.2;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @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.encodeCall(token.transfer, (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.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OAppUpgradeable, Origin } from "@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/OAppUpgradeable.sol";
import { OAppOptionsType3Upgradeable } from "@layerzerolabs/oapp-evm-upgradeable/contracts/oapp/libs/OAppOptionsType3Upgradeable.sol";
import { IOAppMsgInspector } from "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppMsgInspector.sol";
import { OAppPreCrimeSimulatorUpgradeable } from "@layerzerolabs/oapp-evm-upgradeable/contracts/precrime/OAppPreCrimeSimulatorUpgradeable.sol";
import { IOFT, SendParam, OFTLimit, OFTReceipt, OFTFeeDetail, MessagingReceipt, MessagingFee } from "@layerzerolabs/oft-evm/contracts/interfaces/IOFT.sol";
import { OFTMsgCodec } from "@layerzerolabs/oft-evm/contracts/libs/OFTMsgCodec.sol";
import { OFTComposeMsgCodec } from "@layerzerolabs/oft-evm/contracts/libs/OFTComposeMsgCodec.sol";
/**
* @title OFTCore
* @dev Abstract contract for the OftChain (OFT) token.
*/
abstract contract OFTCoreUpgradeable is
IOFT,
OAppUpgradeable,
OAppPreCrimeSimulatorUpgradeable,
OAppOptionsType3Upgradeable
{
using OFTMsgCodec for bytes;
using OFTMsgCodec for bytes32;
struct OFTCoreStorage {
// Address of an optional contract to inspect both 'message' and 'options'
address msgInspector;
}
// keccak256(abi.encode(uint256(keccak256("layerzerov2.storage.oftcore")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OFT_CORE_STORAGE_LOCATION =
0x41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c00;
// @notice Provides a conversion rate when swapping between denominations of SD and LD
// - shareDecimals == SD == shared Decimals
// - localDecimals == LD == local decimals
// @dev Considers that tokens have different decimal amounts on various chains.
// @dev eg.
// For a token
// - locally with 4 decimals --> 1.2345 => uint(12345)
// - remotely with 2 decimals --> 1.23 => uint(123)
// - The conversion rate would be 10 ** (4 - 2) = 100
// @dev If you want to send 1.2345 -> (uint 12345), you CANNOT represent that value on the remote,
// you can only display 1.23 -> uint(123).
// @dev To preserve the dust that would otherwise be lost on that conversion,
// we need to unify a denomination that can be represented on ALL chains inside of the OFT mesh
uint256 public immutable decimalConversionRate;
// @notice Msg types that are used to identify the various OFT operations.
// @dev This can be extended in child contracts for non-default oft operations
// @dev These values are used in things like combineOptions() in OAppOptionsType3.sol.
uint16 public constant SEND = 1;
uint16 public constant SEND_AND_CALL = 2;
event MsgInspectorSet(address inspector);
function _getOFTCoreStorage() internal pure returns (OFTCoreStorage storage $) {
assembly {
$.slot := OFT_CORE_STORAGE_LOCATION
}
}
/**
* @dev Constructor.
* @param _localDecimals The decimals of the token on the local chain (this chain).
* @param _endpoint The address of the LayerZero endpoint.
*/
constructor(uint8 _localDecimals, address _endpoint) OAppUpgradeable(_endpoint) {
if (_localDecimals < sharedDecimals()) revert InvalidLocalDecimals();
decimalConversionRate = 10 ** (_localDecimals - sharedDecimals());
}
/**
* @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 pure virtual returns (bytes4 interfaceId, uint64 version) {
return (type(IOFT).interfaceId, 1);
}
/**
* @dev Initializes the OFTCore contract.
* @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.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OFTCore_init(address _delegate) internal onlyInitializing {
__OApp_init(_delegate);
__OAppPreCrimeSimulator_init();
__OAppOptionsType3_init();
}
function __OFTCore_init_unchained() internal onlyInitializing {}
function msgInspector() public view returns (address) {
OFTCoreStorage storage $ = _getOFTCoreStorage();
return $.msgInspector;
}
/**
* @dev Retrieves the shared decimals of the OFT.
* @return The shared decimals of the OFT.
*
* @dev Sets an implicit cap on the amount of tokens, over uint64.max() will need some sort of outbound cap / totalSupply cap
* Lowest common decimal denominator between chains.
* Defaults to 6 decimal places to provide up to 18,446,744,073,709.551615 units (max uint64).
* For tokens exceeding this totalSupply(), they will need to override the sharedDecimals function with something smaller.
* ie. 4 sharedDecimals would be 1,844,674,407,370,955.1615
*/
function sharedDecimals() public pure virtual returns (uint8) {
return 6;
}
/**
* @dev Sets the message inspector address for the OFT.
* @param _msgInspector The address of the message inspector.
*
* @dev This is an optional contract that can be used to inspect both 'message' and 'options'.
* @dev Set it to address(0) to disable it, or set it to a contract address to enable it.
*/
function setMsgInspector(address _msgInspector) public virtual onlyOwner {
OFTCoreStorage storage $ = _getOFTCoreStorage();
$.msgInspector = _msgInspector;
emit MsgInspectorSet(_msgInspector);
}
/**
* @notice Provides a quote for OFT-related operations.
* @param _sendParam The parameters for the send operation.
* @return oftLimit The OFT limit information.
* @return oftFeeDetails The details of OFT fees.
* @return oftReceipt The OFT receipt information.
*/
function quoteOFT(
SendParam calldata _sendParam
)
external
view
virtual
returns (OFTLimit memory oftLimit, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory oftReceipt)
{
uint256 minAmountLD = 0; // Unused in the default implementation.
uint256 maxAmountLD = type(uint64).max; // Unused in the default implementation.
oftLimit = OFTLimit(minAmountLD, maxAmountLD);
// Unused in the default implementation; reserved for future complex fee details.
oftFeeDetails = new OFTFeeDetail[](0);
// @dev This is the same as the send() operation, but without the actual send.
// - amountSentLD is the amount in local decimals that would be sent from the sender.
// - amountReceivedLD is the amount in local decimals that will be credited to the recipient on the remote OFT instance.
// @dev The amountSentLD MIGHT not equal the amount the user actually receives. HOWEVER, the default does.
(uint256 amountSentLD, uint256 amountReceivedLD) = _debitView(
_sendParam.amountLD,
_sendParam.minAmountLD,
_sendParam.dstEid
);
oftReceipt = OFTReceipt(amountSentLD, amountReceivedLD);
}
/**
* @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 msgFee 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 virtual returns (MessagingFee memory msgFee) {
// @dev mock the amount to receive, this is the same operation used in the send().
// The quote is as similar as possible to the actual send() operation.
(, uint256 amountReceivedLD) = _debitView(_sendParam.amountLD, _sendParam.minAmountLD, _sendParam.dstEid);
// @dev Builds the options and OFT message to quote in the endpoint.
(bytes memory message, bytes memory options) = _buildMsgAndOptions(_sendParam, amountReceivedLD);
// @dev Calculates the LayerZero fee for the send() operation.
return _quote(_sendParam.dstEid, message, options, _payInLzToken);
}
/**
* @dev Executes the send operation.
* @param _sendParam The parameters for the send operation.
* @param _fee The calculated fee for the send() operation.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess funds.
* @return msgReceipt The receipt for 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 virtual returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) {
// @dev Applies the token transfers regarding this send() operation.
// - amountSentLD is the amount in local decimals that was ACTUALLY sent/debited from the sender.
// - amountReceivedLD is the amount in local decimals that will be received/credited to the recipient on the remote OFT instance.
(uint256 amountSentLD, uint256 amountReceivedLD) = _debit(
msg.sender,
_sendParam.amountLD,
_sendParam.minAmountLD,
_sendParam.dstEid
);
// @dev Builds the options and OFT message to quote in the endpoint.
(bytes memory message, bytes memory options) = _buildMsgAndOptions(_sendParam, amountReceivedLD);
// @dev Sends the message to the LayerZero endpoint and returns the LayerZero msg receipt.
msgReceipt = _lzSend(_sendParam.dstEid, message, options, _fee, _refundAddress);
// @dev Formulate the OFT receipt.
oftReceipt = OFTReceipt(amountSentLD, amountReceivedLD);
emit OFTSent(msgReceipt.guid, _sendParam.dstEid, msg.sender, amountSentLD, amountReceivedLD);
}
/**
* @dev Internal function to build the message and options.
* @param _sendParam The parameters for the send() operation.
* @param _amountLD The amount in local decimals.
* @return message The encoded message.
* @return options The encoded options.
*/
function _buildMsgAndOptions(
SendParam calldata _sendParam,
uint256 _amountLD
) internal view virtual returns (bytes memory message, bytes memory options) {
bool hasCompose;
// @dev This generated message has the msg.sender encoded into the payload so the remote knows who the caller is.
(message, hasCompose) = OFTMsgCodec.encode(
_sendParam.to,
_toSD(_amountLD),
// @dev Must be include a non empty bytes if you want to compose, EVEN if you dont need it on the remote.
// EVEN if you dont require an arbitrary payload to be sent... eg. '0x01'
_sendParam.composeMsg
);
// @dev Change the msg type depending if its composed or not.
uint16 msgType = hasCompose ? SEND_AND_CALL : SEND;
// @dev Combine the callers _extraOptions with the enforced options via the OAppOptionsType3.
options = combineOptions(_sendParam.dstEid, msgType, _sendParam.extraOptions);
OFTCoreStorage storage $ = _getOFTCoreStorage();
// @dev Optionally inspect the message and options depending if the OApp owner has set a msg inspector.
// @dev If it fails inspection, needs to revert in the implementation. ie. does not rely on return boolean
address inspector = $.msgInspector; // caches the msgInspector to avoid potential double storage read
if (inspector != address(0)) IOAppMsgInspector(inspector).inspect(message, options);
}
/**
* @dev Internal function to handle the receive on the LayerZero endpoint.
* @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 unique identifier for the received LayerZero message.
* @param _message The encoded message.
* @dev _executor The address of the executor.
* @dev _extraData Additional data.
*/
function _lzReceive(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address /*_executor*/, // @dev unused in the default implementation.
bytes calldata /*_extraData*/ // @dev unused in the default implementation.
) internal virtual override {
// @dev The src sending chain doesnt know the address length on this chain (potentially non-evm)
// Thus everything is bytes32() encoded in flight.
address toAddress = _message.sendTo().bytes32ToAddress();
// @dev Credit the amountLD to the recipient and return the ACTUAL amount the recipient received in local decimals
uint256 amountReceivedLD = _credit(toAddress, _toLD(_message.amountSD()), _origin.srcEid);
if (_message.isComposed()) {
// @dev Proprietary composeMsg format for the OFT.
bytes memory composeMsg = OFTComposeMsgCodec.encode(
_origin.nonce,
_origin.srcEid,
amountReceivedLD,
_message.composeMsg()
);
// @dev Stores the lzCompose payload that will be executed in a separate tx.
// Standardizes functionality for executing arbitrary contract invocation on some non-evm chains.
// @dev The off-chain executor will listen and process the msg based on the src-chain-callers compose options passed.
// @dev The index is used when a OApp needs to compose multiple msgs on lzReceive.
// For default OFT implementation there is only 1 compose msg per lzReceive, thus its always 0.
endpoint.sendCompose(toAddress, _guid, 0 /* the index of the composed message*/, composeMsg);
}
emit OFTReceived(_guid, _origin.srcEid, toAddress, amountReceivedLD);
}
/**
* @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 unique identifier for the received 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 override {
_lzReceive(_origin, _guid, _message, _executor, _extraData);
}
/**
* @dev Check if the 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.
*
* @dev Enables OAppPreCrimeSimulator to check whether a potential Inbound Packet is from a trusted source.
*/
function isPeer(uint32 _eid, bytes32 _peer) public view virtual override returns (bool) {
return peers(_eid) == _peer;
}
/**
* @dev Internal function to remove dust from the given local decimal amount.
* @param _amountLD The amount in local decimals.
* @return amountLD The amount after removing dust.
*
* @dev Prevents the loss of dust when moving amounts between chains with different decimals.
* @dev eg. uint(123) with a conversion rate of 100 becomes uint(100).
*/
function _removeDust(uint256 _amountLD) internal view virtual returns (uint256 amountLD) {
return (_amountLD / decimalConversionRate) * decimalConversionRate;
}
/**
* @dev Internal function to convert an amount from shared decimals into local decimals.
* @param _amountSD The amount in shared decimals.
* @return amountLD The amount in local decimals.
*/
function _toLD(uint64 _amountSD) internal view virtual returns (uint256 amountLD) {
return _amountSD * decimalConversionRate;
}
/**
* @dev Internal function to convert an amount from local decimals into shared decimals.
* @param _amountLD The amount in local decimals.
* @return amountSD The amount in shared decimals.
*/
function _toSD(uint256 _amountLD) internal view virtual returns (uint64 amountSD) {
return uint64(_amountLD / decimalConversionRate);
}
/**
* @dev Internal function to mock the amount mutation from a OFT debit() operation.
* @param _amountLD The amount to send in local decimals.
* @param _minAmountLD The minimum amount to send in local decimals.
* @dev _dstEid The destination endpoint ID.
* @return amountSentLD The amount sent, in local decimals.
* @return amountReceivedLD The amount to be received on the remote chain, in local decimals.
*
* @dev This is where things like fees would be calculated and deducted from the amount to be received on the remote.
*/
function _debitView(
uint256 _amountLD,
uint256 _minAmountLD,
uint32 /*_dstEid*/
) internal view virtual returns (uint256 amountSentLD, uint256 amountReceivedLD) {
// @dev Remove the dust so nothing is lost on the conversion between chains with different decimals for the token.
amountSentLD = _removeDust(_amountLD);
// @dev The amount to send is the same as amount received in the default implementation.
amountReceivedLD = amountSentLD;
// @dev Check for slippage.
if (amountReceivedLD < _minAmountLD) {
revert SlippageExceeded(amountReceivedLD, _minAmountLD);
}
}
/**
* @dev Internal function to perform a debit operation.
* @param _from The address to debit from.
* @param _amountLD The amount to send in local decimals.
* @param _minAmountLD The minimum amount to send in local decimals.
* @param _dstEid The destination endpoint ID.
* @return amountSentLD The amount sent in local decimals.
* @return amountReceivedLD The amount received in local decimals on the remote.
*
* @dev Defined here but are intended to be overriden depending on the OFT implementation.
* @dev Depending on OFT implementation the _amountLD could differ from the amountReceivedLD.
*/
function _debit(
address _from,
uint256 _amountLD,
uint256 _minAmountLD,
uint32 _dstEid
) internal virtual returns (uint256 amountSentLD, uint256 amountReceivedLD);
/**
* @dev Internal function to perform a credit operation.
* @param _to The address to credit.
* @param _amountLD The amount to credit in local decimals.
* @param _srcEid The source endpoint ID.
* @return amountReceivedLD The amount ACTUALLY received in local decimals.
*
* @dev Defined here but are intended to be overriden depending on the OFT implementation.
* @dev Depending on OFT implementation the _amountLD could differ from the amountReceivedLD.
*/
function _credit(
address _to,
uint256 _amountLD,
uint32 _srcEid
) internal virtual returns (uint256 amountReceivedLD);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.0;
// ====================================================================
// _ ______ ___ _______ _
// / \ .' ___ | .' `.|_ __ \ / \
// / _ \ / .' \_| / .-. \ | |__) | / _ \
// / ___ \ | | ____ | | | | | __ / / ___ \
// _/ / \ \_\ `.___] |\ `-' /_| | \ \_ _/ / \ \_
// |____| |____|`._____.' `.___.'|____| |___||____| |____|
// ====================================================================
// ======================== AgoraAccessControl ========================
// ====================================================================
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
/// @title AgoraAccessControl
/// @notice An abstract contract that provides role-based access control with enumerable membership tracking
abstract contract AgoraAccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableSet for EnumerableSet.Bytes32Set;
string public constant ACCESS_CONTROL_MANAGER_ROLE = "ACCESS_CONTROL_MANAGER_ROLE";
/// @notice The AgoraAccessControlStorage struct
/// @param roleData A mapping of role identifier to AgoraAccessControlRoleData to store role data
/// @custom:storage-location erc7201:AgoraAccessControl.AgoraAccessControlStorage
struct AgoraAccessControlStorage {
EnumerableSet.Bytes32Set roles;
mapping(string _role => EnumerableSet.AddressSet membership) roleMembership;
}
//==============================================================================
// Initialization Functions
//==============================================================================
function _initializeAgoraAccessControl(address _initialAdminAddress) internal virtual {
_addRoleToSet({ _role: ACCESS_CONTROL_MANAGER_ROLE });
_setRoleMembership({ _role: ACCESS_CONTROL_MANAGER_ROLE, _member: _initialAdminAddress, _insert: true });
emit RoleAssigned({ role: ACCESS_CONTROL_MANAGER_ROLE, member: _initialAdminAddress });
}
// ============================================================================================
// Procedural Functions
// ============================================================================================
function _addRoleToSet(string memory _role) internal virtual {
// Checks: Role name must be shorter than 32 bytes
if (bytes(_role).length > 32) revert RoleNameTooLong();
_getPointerToAgoraAccessControlStorage().roles.add(bytes32(bytes(_role)));
}
function _removeRoleFromSet(string memory _role) internal virtual {
if (_getPointerToAgoraAccessControlStorage().roleMembership[_role].length() > 0) {
revert CannotRemoveRoleWithMembers({ role: _role });
}
_getPointerToAgoraAccessControlStorage().roles.remove(bytes32(bytes(_role)));
}
function _assignRole(string memory _role, address _member, bool _addRole) internal virtual {
// Checks: Role must exist
_requireRoleExists({ _role: _role });
// Effects: Set the roleMembership to the new _member
_setRoleMembership({ _role: _role, _member: _member, _insert: _addRole });
// Emit event
if (_addRole) emit RoleAssigned({ role: _role, member: _member });
else emit RoleRevoked({ role: _role, member: _member });
}
/// @notice The ```grantAccessControlManagerRole``` function grants `ACCESS_CONTROL_MANAGER_ROLE` to an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @param _member The address to be granted the role
function grantAccessControlManagerRole(address _member) public virtual {
// Checks: Only `ACCESS_CONTROL_MANAGER_ROLE` can grant the role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
_assignRole({ _role: ACCESS_CONTROL_MANAGER_ROLE, _member: _member, _addRole: true });
}
/// @notice The ```revokeAccessControlManagerRole``` function revokes `ACCESS_CONTROL_MANAGER_ROLE` from an address
/// @dev Must be called by an address holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @dev An `ACCESS_CONTROL_MANAGER_ROLE` member can't remove oneself from the role.
/// @param _member The address to be revoked the role
function revokeAccessControlManagerRole(address _member) public virtual {
// Checks: Only `ACCESS_CONTROL_MANAGER_ROLE` can revoke the role
_requireSenderIsRole({ _role: ACCESS_CONTROL_MANAGER_ROLE });
// Checks: cannot revoke oneself as `ACCESS_CONTROL_MANAGER_ROLE`
if (_member == msg.sender) revert CannotRevokeSelf();
_assignRole({ _role: ACCESS_CONTROL_MANAGER_ROLE, _member: _member, _addRole: false });
}
// ============================================================================================
// Internal Effects Functions
// ============================================================================================
/// @notice The ```_setRoleMembership``` function sets the role membership
/// @param _role The role identifier to transfer
/// @param _member The address of the new role
/// @param _insert Whether to add or remove the address from the role
function _setRoleMembership(string memory _role, address _member, bool _insert) internal virtual {
if (_insert) _getPointerToAgoraAccessControlStorage().roleMembership[_role].add(_member);
else _getPointerToAgoraAccessControlStorage().roleMembership[_role].remove(_member);
}
// ============================================================================================
// Internal Checks Functions
// ============================================================================================
/// @notice The ```_roleExists``` function checks if _role exists in the role set
/// @param _role The role identifier to check
/// @return Whether or not _role exists as a known role
function _roleExists(string memory _role) internal view virtual returns (bool) {
return _getPointerToAgoraAccessControlStorage().roles.contains(bytes32(bytes(_role)));
}
/// @notice The ```_requireRoleExists``` function revers if _role does not exist in the role set
/// @param _role The role identifier to check
function _requireRoleExists(string memory _role) internal view virtual {
if (!_roleExists({ _role: _role })) revert RoleDoesNotExist({ role: _role });
}
/// @notice The ```_isRole``` function checks if the member has the role
/// @param _role The role identifier to check
/// @param _member The address to check against the role
/// @return Whether or not the address has the role
function _isRole(string memory _role, address _member) internal view virtual returns (bool) {
return _getPointerToAgoraAccessControlStorage().roleMembership[_role].contains(_member);
}
/// @notice The ```_requireIsRole``` function reverts if member doesn't have the role
/// @param _role The role identifier to check
/// @param _member The address to check against the role
function _requireIsRole(string memory _role, address _member) internal view virtual {
if (!_isRole({ _role: _role, _member: _member })) revert AddressIsNotRole({ role: _role });
}
/// @notice The ```_requireSenderIsRole``` function reverts if msg.sender doesn't have the role
/// @dev This function is to be implemented by a public function
/// @param _role The role identifier to check
function _requireSenderIsRole(string memory _role) internal view virtual {
_requireIsRole({ _role: _role, _member: msg.sender });
}
//==============================================================================
// Public View Functions
//==============================================================================
/// @notice The ```hasRole``` function checks if _member has the role
/// @param _role The role identifier to check
/// @param _member The address to check against the role
/// @return Whether or not _member has the role
function hasRole(string memory _role, address _member) public view virtual returns (bool) {
return _isRole({ _role: _role, _member: _member });
}
/// @notice The ```getRoleMembers``` function returns the members of the role
/// @param _role The role identifier to check
/// @return The members of the role
function getRoleMembers(string memory _role) public view virtual returns (address[] memory) {
EnumerableSet.AddressSet storage _roleMembership = _getPointerToAgoraAccessControlStorage().roleMembership[
_role
];
return _roleMembership.values();
}
/// @notice The ```getAllRoles``` function returns all roles
/// @return _roles The roles
function getAllRoles() public view virtual returns (string[] memory _roles) {
uint256 _length = _getPointerToAgoraAccessControlStorage().roles.length();
_roles = new string[](_length);
for (uint256 i = 0; i < _length; i++) {
_roles[i] = string(abi.encodePacked(_getPointerToAgoraAccessControlStorage().roles.at(i)));
}
}
/// @notice The ```getAccessControlManagerRoleMembers``` function returns the addresses holding `ACCESS_CONTROL_MANAGER_ROLE`
/// @return The array of addresses holding `ACCESS_CONTROL_MANAGER_ROLE`
function getAccessControlManagerRoleMembers() public view virtual returns (address[] memory) {
return getRoleMembers(ACCESS_CONTROL_MANAGER_ROLE);
}
//==============================================================================
// Erc 7201: UnstructuredNamespace Storage Functions
//==============================================================================
/// @notice The ```AGORA_ACCESS_CONTROL_STORAGE_SLOT``` is the storage slot for the AgoraAccessControlStorage struct
/// @dev keccak256(abi.encode(uint256(keccak256("AgoraAccessControlStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 public constant AGORA_ACCESS_CONTROL_STORAGE_SLOT =
0x8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b000;
/// @notice The ```_getPointerToAgoraAccessControlStorage``` function returns a pointer to the AgoraAccessControlStorage struct
/// @return $ A pointer to the AgoraAccessControlStorage struct
function _getPointerToAgoraAccessControlStorage()
internal
pure
virtual
returns (AgoraAccessControlStorage storage $)
{
/// @solidity memory-safe-assembly
assembly {
$.slot := AGORA_ACCESS_CONTROL_STORAGE_SLOT
}
}
// ============================================================================================
// Events
// ============================================================================================
/// @notice The ```RoleAssigned``` event is emitted when the role is assigned
/// @param role The string identifier of the role that was transferred
/// @param member The address of the new role member
event RoleAssigned(string indexed role, address indexed member);
/// @notice The ```RoleRevoked``` event is emitted when the role is revoked
/// @param role The string identifier of the role that was transferred
/// @param member The address of the previous role member
event RoleRevoked(string indexed role, address indexed member);
// ============================================================================================
// Errors
// ============================================================================================
/// @notice Emitted when role is transferred
/// @param role The role identifier
error AddressIsNotRole(string role);
/// @notice Emitted when role name is too long
error RoleNameTooLong();
/// @notice Emitted when role does not exist
error RoleDoesNotExist(string role);
/// @notice Emitted when role still has members
error CannotRemoveRoleWithMembers(string role);
/// @notice Emitted when a member attempts removing oneself
error CannotRevokeSelf();
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.22;
/**
* @title LZRateLimiterUpgradeable
* @dev Abstract contract for implementing rate limiting functionality. This contract provides a basic framework for
* rate limiting how often a function can be executed. It is designed to be inherited by other contracts requiring rate
* limiting capabilities to protect resources or services from excessive use.
* @dev The mechanism here is based on
* https://github.com/LayerZero-Labs/devtools/blob/main/packages/oapp-evm/contracts/oapp/utils/RateLimiter.sol,
* but modified to be upgradeable
* @dev The ordering of transactions within a given block (timestamp) affects the consumed capacity.
* @dev Carefully consider the minimum window duration for the given blockchain. For example, on Ethereum, the minimum
* window duration should be at least 12 seconds. If a window less than 12 seconds is configured, then the rate limit
* will effectively reset with each block, rendering rate limiting ineffective.
* @dev Carefully consider the proportion of the limit to the window. If the limit is much smaller than the window, the
* decay function is lossy. Consider using a limit that is greater than or equal to the window to avoid this. This is
* especially important for blockchains with short average block times.
*
* Example 1: Max rate limit reached at beginning of window. As time continues the amount of in flights comes down.
*
* Rate Limit Config:
* limit: 100 units
* window: 60 seconds
*
* Amount in Flight (units) vs. Time Graph (seconds)
*
* 100 | * - (Max limit reached at beginning of window)
* | *
* | *
* | *
* 50 | * (After 30 seconds only 50 units in flight)
* | *
* | *
* | *
* 0 +--|---|---|---|---|-->(After 60 seconds 0 units are in flight)
* 0 15 30 45 60 (seconds)
*
* Example 2: Max rate limit reached at beginning of window. As time continues the amount of in flights comes down
* allowing for more to be sent. At the 90 second mark, more in flights come in.
*
* Rate Limit Config:
* limit: 100 units
* window: 60 seconds
*
* Amount in Flight (units) vs. Time Graph (seconds)
*
* 100 | * - (Max limit reached at beginning of window)
* | *
* | *
* | *
* 50 | * * (50 inflight)
* | * *
* | * *
* | * *
* 0 +--|--|--|--|--|--|--|--|--|--> Time
* 0 15 30 45 60 75 90 105 120 (seconds)
*
* Example 3: Max rate limit reached at beginning of window. At the 15 second mark, the window gets updated to 60
* seconds and the limit gets updated to 50 units. This scenario shows the direct depiction of "in flight" from the
* previous window affecting the current window.
*
* Initial Rate Limit Config: For first 15 seconds
* limit: 100 units
* window: 30 seconds
*
* Updated Rate Limit Config: Updated at 15 second mark
* limit: 50 units
* window: 60 seconds
*
* Amount in Flight (units) vs. Time Graph (seconds)
* 100 - *
* |*
* | *
* | *
* | *
* | *
* | *
* 75 - | *
* | *
* | *
* | *
* | *
* | *
* | *
* | *
* 50 - | 𐫰 <--(Slope changes at the 15 second mark because of the update.
* | ✧ * Window extended to 60 seconds and limit reduced to 50 units.
* | ✧ ︎ * Because amountInFlight/lastUpdated do not reset, 50 units are
* | ✧ * considered in flight from the previous window and the corresponding
* | ✧ ︎ * decay from the previous rate.)
* | ✧ *
* 25 - | ✧ *
* | ✧ *
* | ✧ *
* | ✧ *
* | ✧ *
* | ✧ *
* | ✧ *
* | ✧ *
* 0 - +---|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----|----> Time
* 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 (seconds)
* [ Initial 30 Second Window ]
* [ --------------- Extended 60 Second Window --------------- ]
*/
abstract contract LZRateLimiterUpgradeable {
/**
* @notice Rate Limit struct.
* @param amountInFlight The amount in the current window.
* @param lastUpdated Timestamp representing the last time the rate limit was checked or updated.
* @param limit This represents the maximum allowed amount within a given window.
* @param window Defines the duration of the rate limiting window.
*/
struct RateLimit {
uint256 amountInFlight;
uint256 lastUpdated;
uint256 limit;
uint256 window;
}
/**
* @notice Rate Limit Configuration struct.
* @param dstEid The destination endpoint id.
* @param limit This represents the maximum allowed amount within a given window.
* @param window Defines the duration of the rate limiting window.
*/
struct LZRateLimitConfig {
uint32 dstEid;
uint256 limit;
uint256 window;
}
/**
* @notice The RateLimiterStorage struct
* @param rateLimits Mapping from destination endpoint id to RateLimit Configurations.
* @custom:storage-location erc7201:LZRateLimiterUpgradeable.LZRateLimiterStorage
*/
struct LZRateLimiterStorage {
mapping(uint32 dstEid => RateLimit limit) rateLimits;
}
/**
* @notice Emitted when _setRateLimits occurs.
* @param rateLimitConfigs An array of `LZRateLimitConfig` structs representing the rate limit configurations set.
* - `dstEid`: The destination endpoint id.
* - `limit`: This represents the maximum allowed amount within a given window.
* - `window`: Defines the duration of the rate limiting window.
*/
event RateLimitsChanged(LZRateLimitConfig[] rateLimitConfigs);
/**
* @notice Error that is thrown when an amount exceeds the rate_limit.
*/
error RateLimitExceeded();
//==============================================================================
// Erc 7201: UnstructuredNamespace Storage Functions
//==============================================================================
/**
* @notice The storage slot for the LZRateLimiterStorage struct
* @dev keccak256(abi.encode(uint256(keccak256("LZRateLimiterUpgradeable.LZRateLimiterStorage")) - 1)) & ~bytes32(uint256(0xff))
*/
bytes32 public constant LZ_RATE_LIMITER_STORAGE_SLOT =
0xb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700;
/**
* @notice Returns a pointer to the RateLimiterStorage struct
* @return $ A pointer to the RateLimiterStorage struct
*/
function _getPointerToLZRateLimiterStorage() internal pure returns (LZRateLimiterStorage storage $) {
/// @solidity memory-safe-assembly
//slither-disable-next-line assembly
assembly {
$.slot := LZ_RATE_LIMITER_STORAGE_SLOT
}
}
//==============================================================================
// Rate Limiting Logic
//==============================================================================
/**
* @notice Get the current amount that can be sent to this destination endpoint id for the given rate limit window.
* @param _dstEid The destination endpoint id.
* @return currentAmountInFlight The current amount that was sent.
* @return amountCanBeSent The amount that can be sent.
*/
function getAmountCanBeSent(
uint32 _dstEid
) external view virtual returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {
RateLimit memory rl = _getPointerToLZRateLimiterStorage().rateLimits[_dstEid];
return _amountCanBeSent(rl.amountInFlight, rl.lastUpdated, rl.limit, rl.window);
}
/**
* @notice Sets the Rate Limit.
* @param _rateLimitConfigs A `LZRateLimitConfig` struct representing the rate limit configuration.
* - `dstEid`: The destination endpoint id.
* - `limit`: This represents the maximum allowed amount within a given window.
* - `window`: Defines the duration of the rate limiting window.
*/
function _setRateLimits(LZRateLimitConfig[] memory _rateLimitConfigs) internal virtual {
unchecked {
for (uint256 i = 0; i < _rateLimitConfigs.length; i++) {
RateLimit storage rl = _getPointerToLZRateLimiterStorage().rateLimits[_rateLimitConfigs[i].dstEid];
// @dev Ensure we checkpoint the existing rate limit as to not retroactively apply the new decay rate.
_outflow(_rateLimitConfigs[i].dstEid, 0);
// @dev Does NOT reset the amountInFlight/lastUpdated of an existing rate limit.
rl.limit = _rateLimitConfigs[i].limit;
rl.window = _rateLimitConfigs[i].window;
}
}
emit RateLimitsChanged(_rateLimitConfigs);
}
/**
* @notice Checks current amount in flight and amount that can be sent for a given rate limit window.
* @param _amountInFlight The amount in the current window.
* @param _lastUpdated Timestamp representing the last time the rate limit was checked or updated.
* @param _limit This represents the maximum allowed amount within a given window.
* @param _window Defines the duration of the rate limiting window.
* @return currentAmountInFlight The amount in the current window.
* @return amountCanBeSent The amount that can be sent.
*/
function _amountCanBeSent(
uint256 _amountInFlight,
uint256 _lastUpdated,
uint256 _limit,
uint256 _window
) internal view virtual returns (uint256 currentAmountInFlight, uint256 amountCanBeSent) {
//slither-disable-next-line timestamp
uint256 timeSinceLastDeposit = block.timestamp - _lastUpdated;
// @dev Presumes linear decay.
uint256 decay = (_limit * timeSinceLastDeposit) / (_window > 0 ? _window : 1); // prevent division by zero
//slither-disable-next-line timestamp
currentAmountInFlight = _amountInFlight <= decay ? 0 : _amountInFlight - decay;
// @dev In the event the _limit is lowered, and the 'in-flight' amount is higher than the _limit, set to 0.
amountCanBeSent = _limit <= currentAmountInFlight ? 0 : _limit - currentAmountInFlight;
}
/**
* @notice Verifies whether the specified amount falls within the rate limit constraints for the targeted
* endpoint ID. On successful verification, it updates amountInFlight and lastUpdated. If the amount exceeds
* the rate limit, the operation reverts.
* @param _dstEid The destination endpoint id.
* @param _amount The amount to check for rate limit constraints.
*/
function _outflow(uint32 _dstEid, uint256 _amount) internal virtual {
// @dev By default dstEid that have not been explicitly set will return amountCanBeSent == 0.
RateLimit storage rl = _getPointerToLZRateLimiterStorage().rateLimits[_dstEid];
(uint256 currentAmountInFlight, uint256 amountCanBeSent) = _amountCanBeSent(
rl.amountInFlight,
rl.lastUpdated,
rl.limit,
rl.window
);
//slither-disable-next-line timestamp
if (_amount > amountCanBeSent) revert RateLimitExceeded();
// @dev Update the storage to contain the new amount and current timestamp.
rl.amountInFlight = currentAmountInFlight + _amount;
rl.lastUpdated = block.timestamp;
}
/**
* @notice To be used when you want to calculate your rate limits as a function of net outbound AND inbound.
* ie. If you move 150 out, and 100 in, you effective inflight should be 50.
* Does not need to update decay values, as the inflow is effective immediately.
* @param _srcEid The source endpoint id.
* @param _amount The amount to inflow back and deduct from amountInFlight.
*/
//slither-disable-next-line dead-code
function _inflow(uint32 _srcEid, uint256 _amount) internal virtual {
RateLimit storage rl = _getPointerToLZRateLimiterStorage().rateLimits[_srcEid];
rl.amountInFlight = _amount >= rl.amountInFlight ? 0 : rl.amountInFlight - _amount;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import { IMessageLibManager } from "./IMessageLibManager.sol";
import { IMessagingComposer } from "./IMessagingComposer.sol";
import { IMessagingChannel } from "./IMessagingChannel.sol";
import { IMessagingContext } from "./IMessagingContext.sol";
struct MessagingParams {
uint32 dstEid;
bytes32 receiver;
bytes message;
bytes options;
bool payInLzToken;
}
struct MessagingReceipt {
bytes32 guid;
uint64 nonce;
MessagingFee fee;
}
struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}
struct Origin {
uint32 srcEid;
bytes32 sender;
uint64 nonce;
}
interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);
event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);
event PacketDelivered(Origin origin, address receiver);
event LzReceiveAlert(
address indexed receiver,
address indexed executor,
Origin origin,
bytes32 guid,
uint256 gas,
uint256 value,
bytes message,
bytes extraData,
bytes reason
);
event LzTokenSet(address token);
event DelegateSet(address sender, address delegate);
function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);
function send(
MessagingParams calldata _params,
address _refundAddress
) external payable returns (MessagingReceipt memory);
function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;
function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);
function initializable(Origin calldata _origin, address _receiver) external view returns (bool);
function lzReceive(
Origin calldata _origin,
address _receiver,
bytes32 _guid,
bytes calldata _message,
bytes calldata _extraData
) external payable;
// oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;
function setLzToken(address _lzToken) external;
function lzToken() external view returns (address);
function nativeToken() external view returns (address);
function setDelegate(address _delegate) external;
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// 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;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { IOAppOptionsType3, EnforcedOptionParam } from "@layerzerolabs/oapp-evm/contracts/oapp/interfaces/IOAppOptionsType3.sol";
/**
* @title OAppOptionsType3
* @dev Abstract contract implementing the IOAppOptionsType3 interface with type 3 options.
*/
abstract contract OAppOptionsType3Upgradeable is IOAppOptionsType3, OwnableUpgradeable {
struct OAppOptionsType3Storage {
// @dev The "msgType" should be defined in the child contract.
mapping(uint32 => mapping(uint16 => bytes)) enforcedOptions;
}
// keccak256(abi.encode(uint256(keccak256("layerzerov2.storage.oappoptionstype3")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OAPP_OPTIONS_TYPE_3_STORAGE_LOCATION =
0x8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea0000;
uint16 internal constant OPTION_TYPE_3 = 3;
function _getOAppOptionsType3Storage() internal pure returns (OAppOptionsType3Storage storage $) {
assembly {
$.slot := OAPP_OPTIONS_TYPE_3_STORAGE_LOCATION
}
}
/**
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppOptionsType3_init() internal onlyInitializing {}
function __OAppOptionsType3_init_unchained() internal onlyInitializing {}
function enforcedOptions(uint32 _eid, uint16 _msgType) public view returns (bytes memory) {
OAppOptionsType3Storage storage $ = _getOAppOptionsType3Storage();
return $.enforcedOptions[_eid][_msgType];
}
/**
* @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 {
OAppOptionsType3Storage storage $ = _getOAppOptionsType3Storage();
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) {
OAppOptionsType3Storage storage $ = _getOAppOptionsType3Storage();
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 calldata _options) internal pure virtual {
uint16 optionsType = uint16(bytes2(_options[0:2]));
if (optionsType != OPTION_TYPE_3) revert InvalidOptions(_options);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title IOAppMsgInspector
* @dev Interface for the OApp Message Inspector, allowing examination of message and options contents.
*/
interface IOAppMsgInspector {
// Custom error message for inspection failure
error InspectionFailed(bytes message, bytes options);
/**
* @notice Allows the inspector to examine LayerZero message contents and optionally throw a revert if invalid.
* @param _message The message payload to be inspected.
* @param _options Additional options or parameters for inspection.
* @return valid A boolean indicating whether the inspection passed (true) or failed (false).
*
* @dev Optionally done as a revert, OR use the boolean provided to handle the failure.
*/
function inspect(bytes calldata _message, bytes calldata _options) external view returns (bool valid);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import { IPreCrime } from "@layerzerolabs/oapp-evm/contracts/precrime/interfaces/IPreCrime.sol";
import { IOAppPreCrimeSimulator, InboundPacket, Origin } from "@layerzerolabs/oapp-evm/contracts/precrime/interfaces/IOAppPreCrimeSimulator.sol";
/**
* @title OAppPreCrimeSimulator
* @dev Abstract contract serving as the base for preCrime simulation functionality in an OApp.
*/
abstract contract OAppPreCrimeSimulatorUpgradeable is IOAppPreCrimeSimulator, OwnableUpgradeable {
struct OAppPreCrimeSimulatorStorage {
// The address of the preCrime implementation.
address preCrime;
}
// keccak256(abi.encode(uint256(keccak256("layerzerov2.storage.oappprecrimesimulator")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OAPP_PRE_CRIME_SIMULATOR_STORAGE_LOCATION =
0xefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b600;
function _getOAppPreCrimeSimulatorStorage() internal pure returns (OAppPreCrimeSimulatorStorage storage $) {
assembly {
$.slot := OAPP_PRE_CRIME_SIMULATOR_STORAGE_LOCATION
}
}
/**
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppPreCrimeSimulator_init() internal onlyInitializing {}
function __OAppPreCrimeSimulator_init_unchained() internal onlyInitializing {}
function preCrime() external view override returns (address) {
OAppPreCrimeSimulatorStorage storage $ = _getOAppPreCrimeSimulatorStorage();
return $.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 {
OAppPreCrimeSimulatorStorage storage $ = _getOAppPreCrimeSimulatorStorage();
$.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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { MessagingReceipt, MessagingFee } from "@layerzerolabs/oapp-evm/contracts/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 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);
error AmountSDOverflowed(uint256 amountSD);
// 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 the fee breakdown and settings data for an OFT. Unused in the default implementation.
* @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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
library OFTComposeMsgCodec {
// Offset constants for decoding composed messages
uint8 private constant NONCE_OFFSET = 8;
uint8 private constant SRC_EID_OFFSET = 12;
uint8 private constant AMOUNT_LD_OFFSET = 44;
uint8 private constant COMPOSE_FROM_OFFSET = 76;
/**
* @dev Encodes a OFT composed message.
* @param _nonce The nonce value.
* @param _srcEid The source endpoint ID.
* @param _amountLD The amount in local decimals.
* @param _composeMsg The composed message.
* @return _msg The encoded Composed message.
*/
function encode(
uint64 _nonce,
uint32 _srcEid,
uint256 _amountLD,
bytes memory _composeMsg // 0x[composeFrom][composeMsg]
) internal pure returns (bytes memory _msg) {
_msg = abi.encodePacked(_nonce, _srcEid, _amountLD, _composeMsg);
}
/**
* @dev Retrieves the nonce for the composed message.
* @param _msg The message.
* @return The nonce value.
*/
function nonce(bytes calldata _msg) internal pure returns (uint64) {
return uint64(bytes8(_msg[:NONCE_OFFSET]));
}
/**
* @dev Retrieves the source endpoint ID for the composed message.
* @param _msg The message.
* @return The source endpoint ID.
*/
function srcEid(bytes calldata _msg) internal pure returns (uint32) {
return uint32(bytes4(_msg[NONCE_OFFSET:SRC_EID_OFFSET]));
}
/**
* @dev Retrieves the amount in local decimals from the composed message.
* @param _msg The message.
* @return The amount in local decimals.
*/
function amountLD(bytes calldata _msg) internal pure returns (uint256) {
return uint256(bytes32(_msg[SRC_EID_OFFSET:AMOUNT_LD_OFFSET]));
}
/**
* @dev Retrieves the composeFrom value from the composed message.
* @param _msg The message.
* @return The composeFrom value.
*/
function composeFrom(bytes calldata _msg) internal pure returns (bytes32) {
return bytes32(_msg[AMOUNT_LD_OFFSET:COMPOSE_FROM_OFFSET]);
}
/**
* @dev Retrieves the composed message.
* @param _msg The message.
* @return The composed message.
*/
function composeMsg(bytes calldata _msg) internal pure returns (bytes memory) {
return _msg[COMPOSE_FROM_OFFSET:];
}
/**
* @dev Converts an address to bytes32.
* @param _addr The address to convert.
* @return The bytes32 representation of the address.
*/
function addressToBytes32(address _addr) internal pure returns (bytes32) {
return bytes32(uint256(uint160(_addr)));
}
/**
* @dev Converts bytes32 to an address.
* @param _b The bytes32 value to convert.
* @return The address representation of bytes32.
*/
function bytes32ToAddress(bytes32 _b) internal pure returns (address) {
return address(uint160(uint256(_b)));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
import {Arrays} from "../Arrays.sol";
import {Math} from "../math/Math.sol";
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
* - Set can be cleared (all elements removed) in O(n).
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* The following types are supported:
*
* - `bytes32` (`Bytes32Set`) since v3.3.0
* - `address` (`AddressSet`) since v3.3.0
* - `uint256` (`UintSet`) since v3.3.0
* - `string` (`StringSet`) since v5.4.0
* - `bytes` (`BytesSet`) since v5.4.0
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: This function has an unbounded cost that scales with set size. Developers should keep in mind that
* using it may render the function uncallable if the set grows to the point where clearing it consumes too much
* gas to fit in a block.
*/
function _clear(Set storage set) private {
uint256 len = _length(set);
for (uint256 i = 0; i < len; ++i) {
delete set._positions[set._values[i]];
}
Arrays.unsafeSetLength(set._values, 0);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set, uint256 start, uint256 end) private view returns (bytes32[] memory) {
unchecked {
end = Math.min(end, _length(set));
start = Math.min(start, end);
uint256 len = end - start;
bytes32[] memory result = new bytes32[](len);
for (uint256 i = 0; i < len; ++i) {
result[i] = Arrays.unsafeAccess(set._values, start + i).value;
}
return result;
}
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(Bytes32Set storage set) internal {
_clear(set._inner);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set, uint256 start, uint256 end) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner, start, end);
bytes32[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(AddressSet storage set) internal {
_clear(set._inner);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set, uint256 start, uint256 end) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner, start, end);
address[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(UintSet storage set) internal {
_clear(set._inner);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set, uint256 start, uint256 end) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner, start, end);
uint256[] memory result;
assembly ("memory-safe") {
result := store
}
return result;
}
struct StringSet {
// Storage of set values
string[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(string value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(StringSet storage set, string memory value) internal returns (bool) {
if (!contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(StringSet storage set, string memory value) internal returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
string memory lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(StringSet storage set) internal {
uint256 len = length(set);
for (uint256 i = 0; i < len; ++i) {
delete set._positions[set._values[i]];
}
Arrays.unsafeSetLength(set._values, 0);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(StringSet storage set, string memory value) internal view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(StringSet storage set) internal view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(StringSet storage set, uint256 index) internal view returns (string memory) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(StringSet storage set) internal view returns (string[] memory) {
return set._values;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(StringSet storage set, uint256 start, uint256 end) internal view returns (string[] memory) {
unchecked {
end = Math.min(end, length(set));
start = Math.min(start, end);
uint256 len = end - start;
string[] memory result = new string[](len);
for (uint256 i = 0; i < len; ++i) {
result[i] = Arrays.unsafeAccess(set._values, start + i).value;
}
return result;
}
}
struct BytesSet {
// Storage of set values
bytes[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(BytesSet storage set, bytes memory value) internal returns (bool) {
if (!contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(BytesSet storage set, bytes memory value) internal returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes memory lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Removes all the values from a set. O(n).
*
* WARNING: Developers should keep in mind that this function has an unbounded cost and using it may render the
* function uncallable if the set grows to the point where clearing it consumes too much gas to fit in a block.
*/
function clear(BytesSet storage set) internal {
uint256 len = length(set);
for (uint256 i = 0; i < len; ++i) {
delete set._positions[set._values[i]];
}
Arrays.unsafeSetLength(set._values, 0);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(BytesSet storage set, bytes memory value) internal view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(BytesSet storage set) internal view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(BytesSet storage set, uint256 index) internal view returns (bytes memory) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(BytesSet storage set) internal view returns (bytes[] memory) {
return set._values;
}
/**
* @dev Return a slice of the set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(BytesSet storage set, uint256 start, uint256 end) internal view returns (bytes[] memory) {
unchecked {
end = Math.min(end, length(set));
start = Math.min(start, end);
uint256 len = end - start;
bytes[] memory result = new bytes[](len);
for (uint256 i = 0; i < len; ++i) {
result[i] = Arrays.unsafeAccess(set._values, start + i).value;
}
return result;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
struct SetConfigParam {
uint32 eid;
uint32 configType;
bytes config;
}
interface IMessageLibManager {
struct Timeout {
address lib;
uint256 expiry;
}
event LibraryRegistered(address newLib);
event DefaultSendLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
event SendLibrarySet(address sender, uint32 eid, address newLib);
event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);
function registerLibrary(address _lib) external;
function isRegisteredLibrary(address _lib) external view returns (bool);
function getRegisteredLibraries() external view returns (address[] memory);
function setDefaultSendLibrary(uint32 _eid, address _newLib) external;
function defaultSendLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function defaultReceiveLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
function isSupportedEid(uint32 _eid) external view returns (bool);
function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);
/// ------------------- OApp interfaces -------------------
function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;
function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);
function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);
function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);
function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;
function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
function getConfig(
address _oapp,
address _lib,
uint32 _eid,
uint32 _configType
) external view returns (bytes memory config);
}// 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;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingChannel {
event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
function eid() external view returns (uint32);
// this is an emergency function if a message cannot be verified for some reasons
// required to provide _nextNonce to avoid race condition
function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;
function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);
function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);
function inboundPayloadHash(
address _receiver,
uint32 _srcEid,
bytes32 _sender,
uint64 _nonce
) external view returns (bytes32);
function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
}// 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);
}// 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);
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;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.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);
}// 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);
}// 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);
}// 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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/Arrays.sol)
// This file was procedurally generated from scripts/generate/templates/Arrays.js.
pragma solidity ^0.8.20;
import {Comparators} from "./Comparators.sol";
import {SlotDerivation} from "./SlotDerivation.sol";
import {StorageSlot} from "./StorageSlot.sol";
import {Math} from "./math/Math.sol";
/**
* @dev Collection of functions related to array types.
*/
library Arrays {
using SlotDerivation for bytes32;
using StorageSlot for bytes32;
/**
* @dev Sort an array of uint256 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
uint256[] memory array,
function(uint256, uint256) pure returns (bool) comp
) internal pure returns (uint256[] memory) {
_quickSort(_begin(array), _end(array), comp);
return array;
}
/**
* @dev Variant of {sort} that sorts an array of uint256 in increasing order.
*/
function sort(uint256[] memory array) internal pure returns (uint256[] memory) {
sort(array, Comparators.lt);
return array;
}
/**
* @dev Sort an array of address (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
address[] memory array,
function(address, address) pure returns (bool) comp
) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of address in increasing order.
*/
function sort(address[] memory array) internal pure returns (address[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Sort an array of bytes32 (in memory) following the provided comparator function.
*
* This function does the sorting "in place", meaning that it overrides the input. The object is returned for
* convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array.
*
* NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the
* array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful
* when executing this as part of a transaction. If the array being sorted is too large, the sort operation may
* consume more gas than is available in a block, leading to potential DoS.
*
* IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way.
*/
function sort(
bytes32[] memory array,
function(bytes32, bytes32) pure returns (bool) comp
) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), _castToUint256Comp(comp));
return array;
}
/**
* @dev Variant of {sort} that sorts an array of bytes32 in increasing order.
*/
function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) {
sort(_castToUint256Array(array), Comparators.lt);
return array;
}
/**
* @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops
* at end (exclusive). Sorting follows the `comp` comparator.
*
* Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls.
*
* IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should
* be used only if the limits are within a memory array.
*/
function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure {
unchecked {
if (end - begin < 0x40) return;
// Use first element as pivot
uint256 pivot = _mload(begin);
// Position where the pivot should be at the end of the loop
uint256 pos = begin;
for (uint256 it = begin + 0x20; it < end; it += 0x20) {
if (comp(_mload(it), pivot)) {
// If the value stored at the iterator's position comes before the pivot, we increment the
// position of the pivot and move the value there.
pos += 0x20;
_swap(pos, it);
}
}
_swap(begin, pos); // Swap pivot into place
_quickSort(begin, pos, comp); // Sort the left side of the pivot
_quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot
}
}
/**
* @dev Pointer to the memory location of the first element of `array`.
*/
function _begin(uint256[] memory array) private pure returns (uint256 ptr) {
assembly ("memory-safe") {
ptr := add(array, 0x20)
}
}
/**
* @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word
* that comes just after the last element of the array.
*/
function _end(uint256[] memory array) private pure returns (uint256 ptr) {
unchecked {
return _begin(array) + array.length * 0x20;
}
}
/**
* @dev Load memory word (as a uint256) at location `ptr`.
*/
function _mload(uint256 ptr) private pure returns (uint256 value) {
assembly {
value := mload(ptr)
}
}
/**
* @dev Swaps the elements memory location `ptr1` and `ptr2`.
*/
function _swap(uint256 ptr1, uint256 ptr2) private pure {
assembly {
let value1 := mload(ptr1)
let value2 := mload(ptr2)
mstore(ptr1, value2)
mstore(ptr2, value1)
}
}
/// @dev Helper: low level cast address memory array to uint256 memory array
function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 memory array to uint256 memory array
function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast address comp function to uint256 comp function
function _castToUint256Comp(
function(address, address) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/// @dev Helper: low level cast bytes32 comp function to uint256 comp function
function _castToUint256Comp(
function(bytes32, bytes32) pure returns (bool) input
) private pure returns (function(uint256, uint256) pure returns (bool) output) {
assembly {
output := input
}
}
/**
* @dev Searches a sorted `array` and returns the first index that contains
* a value greater or equal to `element`. If no such index exists (i.e. all
* values in the array are strictly less than `element`), the array length is
* returned. Time complexity O(log n).
*
* NOTE: The `array` is expected to be sorted in ascending order, and to
* contain no repeated elements.
*
* IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks
* support for repeated elements in the array. The {lowerBound} function should
* be used instead.
*/
function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
low = mid + 1;
}
}
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && unsafeAccess(array, low - 1).value == element) {
return low - 1;
} else {
return low;
}
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value greater or equal than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound].
*/
function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Searches an `array` sorted in ascending order and returns the first
* index that contains a value strictly greater than `element`. If no such index
* exists (i.e. all values in the array are strictly less than `element`), the array
* length is returned. Time complexity O(log n).
*
* See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound].
*/
function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeAccess(array, mid).value > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Same as {lowerBound}, but with an array in memory.
*/
function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) < element) {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
} else {
high = mid;
}
}
return low;
}
/**
* @dev Same as {upperBound}, but with an array in memory.
*/
function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) {
uint256 low = 0;
uint256 high = array.length;
if (high == 0) {
return 0;
}
while (low < high) {
uint256 mid = Math.average(low, high);
// Note that mid will always be strictly less than high (i.e. it will be a valid array index)
// because Math.average rounds towards zero (it does integer division with truncation).
if (unsafeMemoryAccess(array, mid) > element) {
high = mid;
} else {
// this cannot overflow because mid < high
unchecked {
low = mid + 1;
}
}
}
return low;
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getAddressSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytes32Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getUint256Slot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(bytes[] storage arr, uint256 pos) internal pure returns (StorageSlot.BytesSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getBytesSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeAccess(string[] storage arr, uint256 pos) internal pure returns (StorageSlot.StringSlot storage) {
bytes32 slot;
assembly ("memory-safe") {
slot := arr.slot
}
return slot.deriveArray().offset(pos).getStringSlot();
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(bytes[] memory arr, uint256 pos) internal pure returns (bytes memory res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check.
*
* WARNING: Only use if you are certain `pos` is lower than the array length.
*/
function unsafeMemoryAccess(string[] memory arr, uint256 pos) internal pure returns (string memory res) {
assembly {
res := mload(add(add(arr, 0x20), mul(pos, 0x20)))
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(address[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes32[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(uint256[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(bytes[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
/**
* @dev Helper to set the length of a dynamic array. Directly writing to `.length` is forbidden.
*
* WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased.
*/
function unsafeSetLength(string[] storage array, uint256 len) internal {
assembly ("memory-safe") {
sstore(array.slot, len)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}// 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];
}
}
}// 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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides a set of functions to compare values.
*
* _Available since v5.1._
*/
library Comparators {
function lt(uint256 a, uint256 b) internal pure returns (bool) {
return a < b;
}
function gt(uint256 a, uint256 b) internal pure returns (bool) {
return a > b;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/SlotDerivation.sol)
// This file was procedurally generated from scripts/generate/templates/SlotDerivation.js.
pragma solidity ^0.8.20;
/**
* @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots
* corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by
* the solidity language / compiler.
*
* See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].
*
* Example usage:
* ```solidity
* contract Example {
* // Add the library methods
* using StorageSlot for bytes32;
* using SlotDerivation for bytes32;
*
* // Declare a namespace
* string private constant _NAMESPACE = "<namespace>"; // eg. OpenZeppelin.Slot
*
* function setValueInNamespace(uint256 key, address newValue) internal {
* _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
* }
*
* function getValueInNamespace(uint256 key) internal view returns (address) {
* return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
* }
* }
* ```
*
* TIP: Consider using this library along with {StorageSlot}.
*
* NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking
* upgrade safety will ignore the slots accessed through this library.
*
* _Available since v5.1._
*/
library SlotDerivation {
/**
* @dev Derive an ERC-7201 slot from a string (namespace).
*/
function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {
assembly ("memory-safe") {
mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
slot := and(keccak256(0x00, 0x20), not(0xff))
}
}
/**
* @dev Add an offset to a slot to get the n-th element of a structure or an array.
*/
function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {
unchecked {
return bytes32(uint256(slot) + pos);
}
}
/**
* @dev Derive the location of the first element in an array from the slot where the length is stored.
*/
function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, slot)
result := keccak256(0x00, 0x20)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, and(key, shr(96, not(0))))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, iszero(iszero(key)))
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
mstore(0x00, key)
mstore(0x20, slot)
result := keccak256(0x00, 0x40)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
/**
* @dev Derive the location of a mapping element from the key.
*/
function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {
assembly ("memory-safe") {
let length := mload(key)
let begin := add(key, 0x20)
let end := add(begin, length)
let cache := mload(end)
mstore(end, slot)
result := keccak256(begin, add(length, 0x20))
mstore(end, cache)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool 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.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @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
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
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
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
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
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
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
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
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
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
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
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
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
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
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
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
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
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
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
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
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
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
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
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
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
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
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
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
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
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
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
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
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
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
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
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
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
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
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
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
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
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
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
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
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
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
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
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
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
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
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
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
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
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
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
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
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
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
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
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
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
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
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
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @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
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @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
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @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
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @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
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @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
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @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
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @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
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @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
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @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
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @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
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @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
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @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
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @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
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @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
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @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
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @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
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @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
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @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
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @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
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @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
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @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
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @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
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @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
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @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
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @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
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @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
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @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
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @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
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @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
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @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
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
import { Packet } from "../../interfaces/ISendLib.sol";
import { AddressCast } from "../../libs/AddressCast.sol";
library PacketV1Codec {
using AddressCast for address;
using AddressCast for bytes32;
uint8 internal constant PACKET_VERSION = 1;
// header (version + nonce + path)
// version
uint256 private constant PACKET_VERSION_OFFSET = 0;
// nonce
uint256 private constant NONCE_OFFSET = 1;
// path
uint256 private constant SRC_EID_OFFSET = 9;
uint256 private constant SENDER_OFFSET = 13;
uint256 private constant DST_EID_OFFSET = 45;
uint256 private constant RECEIVER_OFFSET = 49;
// payload (guid + message)
uint256 private constant GUID_OFFSET = 81; // keccak256(nonce + path)
uint256 private constant MESSAGE_OFFSET = 113;
function encode(Packet memory _packet) internal pure returns (bytes memory encodedPacket) {
encodedPacket = abi.encodePacked(
PACKET_VERSION,
_packet.nonce,
_packet.srcEid,
_packet.sender.toBytes32(),
_packet.dstEid,
_packet.receiver,
_packet.guid,
_packet.message
);
}
function encodePacketHeader(Packet memory _packet) internal pure returns (bytes memory) {
return
abi.encodePacked(
PACKET_VERSION,
_packet.nonce,
_packet.srcEid,
_packet.sender.toBytes32(),
_packet.dstEid,
_packet.receiver
);
}
function encodePayload(Packet memory _packet) internal pure returns (bytes memory) {
return abi.encodePacked(_packet.guid, _packet.message);
}
function header(bytes calldata _packet) internal pure returns (bytes calldata) {
return _packet[0:GUID_OFFSET];
}
function version(bytes calldata _packet) internal pure returns (uint8) {
return uint8(bytes1(_packet[PACKET_VERSION_OFFSET:NONCE_OFFSET]));
}
function nonce(bytes calldata _packet) internal pure returns (uint64) {
return uint64(bytes8(_packet[NONCE_OFFSET:SRC_EID_OFFSET]));
}
function srcEid(bytes calldata _packet) internal pure returns (uint32) {
return uint32(bytes4(_packet[SRC_EID_OFFSET:SENDER_OFFSET]));
}
function sender(bytes calldata _packet) internal pure returns (bytes32) {
return bytes32(_packet[SENDER_OFFSET:DST_EID_OFFSET]);
}
function senderAddressB20(bytes calldata _packet) internal pure returns (address) {
return sender(_packet).toAddress();
}
function dstEid(bytes calldata _packet) internal pure returns (uint32) {
return uint32(bytes4(_packet[DST_EID_OFFSET:RECEIVER_OFFSET]));
}
function receiver(bytes calldata _packet) internal pure returns (bytes32) {
return bytes32(_packet[RECEIVER_OFFSET:GUID_OFFSET]);
}
function receiverB20(bytes calldata _packet) internal pure returns (address) {
return receiver(_packet).toAddress();
}
function guid(bytes calldata _packet) internal pure returns (bytes32) {
return bytes32(_packet[GUID_OFFSET:MESSAGE_OFFSET]);
}
function message(bytes calldata _packet) internal pure returns (bytes calldata) {
return bytes(_packet[MESSAGE_OFFSET:]);
}
function payload(bytes calldata _packet) internal pure returns (bytes calldata) {
return bytes(_packet[GUID_OFFSET:]);
}
function payloadHash(bytes calldata _packet) internal pure returns (bytes32) {
return keccak256(payload(_packet));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}// 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;
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
library AddressCast {
error AddressCast_InvalidSizeForAddress();
error AddressCast_InvalidAddress();
function toBytes32(bytes calldata _addressBytes) internal pure returns (bytes32 result) {
if (_addressBytes.length > 32) revert AddressCast_InvalidAddress();
result = bytes32(_addressBytes);
unchecked {
uint256 offset = 32 - _addressBytes.length;
result = result >> (offset * 8);
}
}
function toBytes32(address _address) internal pure returns (bytes32 result) {
result = bytes32(uint256(uint160(_address)));
}
function toBytes(bytes32 _addressBytes32, uint256 _size) internal pure returns (bytes memory result) {
if (_size == 0 || _size > 32) revert AddressCast_InvalidSizeForAddress();
result = new bytes(_size);
unchecked {
uint256 offset = 256 - _size * 8;
assembly {
mstore(add(result, 32), shl(offset, _addressBytes32))
}
}
}
function toAddress(bytes32 _addressBytes32) internal pure returns (address result) {
result = address(uint160(uint256(_addressBytes32)));
}
function toAddress(bytes calldata _addressBytes) internal pure returns (address result) {
if (_addressBytes.length != 20) revert AddressCast_InvalidAddress();
result = address(bytes20(_addressBytes));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
}// 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);
}{
"remappings": [
"stable-swap/=lib/stable-swap-dev/src/",
"forge-std/=lib/forge-std/src/",
"agora-std/=lib/agora-standard-solidity/src/",
"createx/=node_modules/createx/src/",
"@interfaces/=src/interfaces/",
"@utils/=src/sol-utils/",
"@swap-actions/=src/actions/stable-swap/",
"@testnet-actions/=src/actions/testnet/",
"@check-actions/=src/actions/check/",
"@openzeppelin/=lib/layerzero-dev/node_modules/@openzeppelin/",
"@layerzerolabs/=lib/layerzero-dev/node_modules/@layerzerolabs/",
"agora-contracts/=lib/layerzero-dev/node_modules/agora-contracts/src/contracts/",
"@chainlink/=lib/agora-standard-solidity/node_modules/@chainlink/",
"@eth-optimism/=lib/agora-standard-solidity/node_modules/@eth-optimism/",
"agora-contracts-old/=node_modules/agora-contracts-old/",
"agora-dollar-dev/=node_modules/agora-dollar-dev/",
"agora-dollar-evm-dev/=lib/agora-dollar-evm-dev/src/",
"agora-dollar/=lib/layerzero-dev/node_modules/agora-dollar/src/",
"agora-standard-solidity/=lib/agora-standard-solidity/src/",
"contracts/=node_modules/agora-dollar-dev/src/contracts/",
"ds-test/=node_modules/ds-test/",
"hardhat-deploy/=lib/layerzero-dev/node_modules/hardhat-deploy/",
"hardhat/=lib/layerzero-dev/node_modules/hardhat/",
"interfaces/=node_modules/agora-dollar-dev/src/contracts/interfaces/",
"layerzero-dev/=lib/layerzero-dev/contracts/",
"openzeppelin/=node_modules/createx/lib/openzeppelin-contracts/contracts/",
"script/=node_modules/agora-dollar-dev/src/script/",
"solady/=node_modules/solady/",
"solidity-bytes-utils/=lib/agora-standard-solidity/node_modules/solidity-bytes-utils/",
"stable-swap-dev/=lib/stable-swap-dev/src/",
"test/=node_modules/agora-dollar-dev/src/test/"
],
"optimizer": {
"enabled": true,
"runs": 100000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_lzEndpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"role","type":"string"}],"name":"AddressIsNotRole","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountSD","type":"uint256"}],"name":"AmountSDOverflowed","type":"error"},{"inputs":[],"name":"BurnFailed","type":"error"},{"inputs":[{"internalType":"string","name":"role","type":"string"}],"name":"CannotRemoveRoleWithMembers","type":"error"},{"inputs":[],"name":"CannotRevokeSelf","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLocalDecimals","type":"error"},{"inputs":[{"internalType":"bytes","name":"options","type":"bytes"}],"name":"InvalidOptions","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[],"name":"MintFailed","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":[],"name":"NotInitializing","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":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"RateLimitExceeded","type":"error"},{"inputs":[{"internalType":"string","name":"role","type":"string"}],"name":"RoleDoesNotExist","type":"error"},{"inputs":[],"name":"RoleNameTooLong","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"SimulationResult","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"}],"name":"SlippageExceeded","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"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":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"inspector","type":"address"}],"name":"MsgInspectorSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"guid","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"srcEid","type":"uint32"},{"indexed":true,"internalType":"address","name":"toAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"name":"OFTReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"guid","type":"bytes32"},{"indexed":false,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":true,"internalType":"address","name":"fromAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"name":"OFTSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"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":"preCrimeAddress","type":"address"}],"name":"PreCrimeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32[]","name":"_guids","type":"bytes32[]"},{"indexed":false,"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"RateLimiterGUIDExemption","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"indexed":false,"internalType":"struct LZRateLimiterUpgradeable.LZRateLimitConfig[]","name":"rateLimitConfigs","type":"tuple[]"}],"name":"RateLimitsChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"role","type":"string"},{"indexed":true,"internalType":"address","name":"member","type":"address"}],"name":"RoleAssigned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"role","type":"string"},{"indexed":true,"internalType":"address","name":"member","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"ACCESS_CONTROL_MANAGER_ROLE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AGORA_ACCESS_CONTROL_STORAGE_SLOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AGORA_RATE_LIMITER_STORAGE_SLOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LZ_RATE_LIMITER_STORAGE_SLOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_LIMIT_EXEMPT_ROLE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"RATE_LIMIT_MANAGER_ROLE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SEND","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SEND_AND_CALL","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"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"}],"name":"allowInitializePath","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"approvalRequired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address[]","name":"_members","type":"address[]"}],"name":"batchGrantRateLimitExemptRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_members","type":"address[]"}],"name":"batchRevokeRateLimitExemptRole","outputs":[],"stateMutability":"nonpayable","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":"decimalConversionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAccessControlManagerRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllRoles","outputs":[{"internalType":"string[]","name":"_roles","type":"string[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAmountCanBeReceived","outputs":[{"internalType":"uint256","name":"currentAmountInFlight","type":"uint256"},{"internalType":"uint256","name":"amountCanBeReceived","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAmountCanBeSent","outputs":[{"internalType":"uint256","name":"currentAmountInFlight","type":"uint256"},{"internalType":"uint256","name":"amountCanBeSent","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"getAmountCanBeSent","outputs":[{"internalType":"uint256","name":"currentAmountInFlight","type":"uint256"},{"internalType":"uint256","name":"amountCanBeSent","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPauserRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRateLimitExemptRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRateLimitManagerRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRateLimits","outputs":[{"components":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"internalType":"struct AgoraRateLimiter.RateLimitConfig","name":"_outboundRateLimit","type":"tuple"},{"components":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"internalType":"struct AgoraRateLimiter.RateLimitConfig","name":"_inboundRateLimit","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_role","type":"string"}],"name":"getRoleMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"grantAccessControlManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"grantPauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"grantRateLimitManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_role","type":"string"},{"internalType":"address","name":"_member","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"implementationAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"},{"internalType":"address","name":"_initialOwner","type":"address"},{"internalType":"address","name":"_initialAccessControlManager","type":"address"},{"internalType":"address","name":"_initialPauser","type":"address"},{"internalType":"address","name":"_initialRateLimitManager","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"bytes32","name":"_guid","type":"bytes32"}],"name":"isRateLimitExemptGuid","outputs":[{"internalType":"bool","name":"_isExempt","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":"msgInspector","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"oftVersion","outputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"},{"internalType":"uint64","name":"version","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"}],"name":"peers","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preCrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxyAdminAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"}],"name":"quoteOFT","outputs":[{"components":[{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"uint256","name":"maxAmountLD","type":"uint256"}],"internalType":"struct OFTLimit","name":"oftLimit","type":"tuple"},{"components":[{"internalType":"int256","name":"feeAmountLD","type":"int256"},{"internalType":"string","name":"description","type":"string"}],"internalType":"struct OFTFeeDetail[]","name":"oftFeeDetails","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"internalType":"struct OFTReceipt","name":"oftReceipt","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"},{"internalType":"bool","name":"_payInLzToken","type":"bool"}],"name":"quoteSend","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"msgFee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"revokeAccessControlManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"revokePauserRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_member","type":"address"}],"name":"revokeRateLimitManagerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"bytes32","name":"to","type":"bytes32"},{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"},{"internalType":"bytes","name":"extraOptions","type":"bytes"},{"internalType":"bytes","name":"composeMsg","type":"bytes"},{"internalType":"bytes","name":"oftCmd","type":"bytes"}],"internalType":"struct SendParam","name":"_sendParam","type":"tuple"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"_fee","type":"tuple"},{"internalType":"address","name":"_refundAddress","type":"address"}],"name":"send","outputs":[{"components":[{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"internalType":"struct MessagingReceipt","name":"msgReceipt","type":"tuple"},{"components":[{"internalType":"uint256","name":"amountSentLD","type":"uint256"},{"internalType":"uint256","name":"amountReceivedLD","type":"uint256"}],"internalType":"struct OFTReceipt","name":"oftReceipt","type":"tuple"}],"stateMutability":"payable","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":"address","name":"_msgInspector","type":"address"}],"name":"setMsgInspector","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":"_preCrime","type":"address"}],"name":"setPreCrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_guids","type":"bytes32[]"},{"internalType":"bool","name":"_isExempt","type":"bool"}],"name":"setRateLimitExemptGuids","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"internalType":"struct AgoraRateLimiter.RateLimitConfig","name":"_outbound","type":"tuple"},{"components":[{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"window","type":"uint256"}],"internalType":"struct AgoraRateLimiter.RateLimitConfig","name":"_inbound","type":"tuple"}],"name":"setRateLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sharedDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"components":[{"internalType":"uint256","name":"major","type":"uint256"},{"internalType":"uint256","name":"minor","type":"uint256"},{"internalType":"uint256","name":"patch","type":"uint256"}],"internalType":"struct AgoraMintBurnOFTAdapter.Version","name":"_version","type":"tuple"}],"stateMutability":"pure","type":"function"}]Contract Creation Code
60e0806040523461021f57604081615999803803809161001f8285610236565b83398101031261021f5761003e60206100378361026d565b920161026d565b60405163313ce56760e01b81526001600160a01b0390921691602081600481865afa90811561022b575f916101e8575b506001600160a01b0390911660805260ff16600681106101d9576005190160ff81116101c55760ff16604d81116101c557600a0a60a05260c0525f5160206159795f395f51905f525460ff8160401c166101b6576002600160401b03196001600160401b03821601610160575b6040516156f79081610282823960805181818161097c01528181610c9b01528181610e080152818161272501528181612f14015281816134e70152818161375301526148c1015260a051818181610b0001528181611b7101528181612e3d015281816146520152614c43015260c0518181816103e501528181610b7601526147240152f35b6001600160401b0319166001600160401b039081175f5160206159795f395f51905f52556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a15f6100db565b63f92ee8a960e01b5f5260045ffd5b634e487b7160e01b5f52601160045260245ffd5b6301e9714b60e41b5f5260045ffd5b90506020813d602011610223575b8161020360209383610236565b8101031261021f57519060ff8216820361021f579060ff61006e565b5f80fd5b3d91506101f6565b6040513d5f823e3d90fd5b601f909101601f19168101906001600160401b0382119082101761025957604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b038216820361021f5756fe60806040526004361015610011575f80fd5b5f5f3560e01c80630d35b4151461387c578063111ecdad1461380c57806313137d651461372b578063134d4f25146136f25780631459457a146132c7578063156a0d0f1461326857806315aefe3e1461322e57806316ee2ff6146131cd57806317442b701461318d5780631a3e6c57146131505780631f5e133414613116578063309e170f146130c8578063322922a21461306f5780633400288b14612fc75780633b6f743b14612d9e5780633f4ba83a14612ca0578063414c5f5014612c665780634592d72314612c10578063491bc11f14612bab5780634a2d53ff14612b155780634d0da67c14612abc5780634f39ceb414612a8357806352ae287914612a4a57806354fd4d50146129da5780635535d461146128985780635979e755146128275780635a0dfe4d146127a95780635c975abb146127495780635e280f11146126da5780636191cae01461258957806365cd0e491461254c5780636c11c21c146124fe5780636c9cd097146124615780636fc1b31e14612376578063715018a61461229a57806378f41c471461214c5780637d25a05e146121085780637f7712b4146120cb578063815170d31461207d578063820813b914611dd657806382413eac14611d515780638456cb5914611c79578063851937e114611c3f578063857749b014611c055780638da5cb5b14611b94578063963efcaa14611b3b5780639f68b96414611b01578063b027551514611ab3578063b731ea0a14611a42578063b97a2319146119d1578063b98bd070146115e1578063bb0b6a5314611568578063bc70b354146114f7578063bd815db0146111c1578063bebcab5614611168578063c272198d14611119578063c607cb7b146110ad578063c7c7f5b314610a1e578063ca5eb5e114610924578063d045a0dc146108d7578063d4243885146107ec578063e63ab1e91461079a578063ec6898e214610747578063f2bcac3d14610540578063f2fde38b146104f8578063f835b38d14610464578063f865af0814610409578063fc0c546a1461039a5763ff7bd03d14610311575f80fd5b346103975760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359063ffffffff8216820361039757602061038b8363ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f205490565b60405190602435148152f35b80fd5b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610444613ab0565b61045461044f613e85565b6149e2565b61045c613f91565b614b4a565b80f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761049c613ab0565b6104a761044f613e85565b3373ffffffffffffffffffffffffffffffffffffffff8216146104d0576104619061045c613e85565b6004827f373d7529000000000000000000000000000000000000000000000000000000008152fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610533613ab0565b61053b614baf565b6144b6565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b000549061059b82613d30565b916105a96040519384613c7a565b8083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06105d682613d30565b01825b8181106107345750507f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00054825b828110610691575050506040519182916020830160208452825180915260408401602060408360051b870101940192905b82821061064657505050500390f35b91936020610681827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc060019597998495030186528851613a3f565b9601920192018594939192610637565b9293919281811015610707576001907f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0008652806020872001548660031b1c604051906020820152602081526106e7604082613c7a565b6106f1828661403f565b526106fc818561403f565b500193929193610606565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b60606020828701810191909152016105d9565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610782613ab0565b61078d61044f613e85565b610795613f56565b614a64565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613f91565b604051918291602083526020830190613a3f565b0390f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c2427760602073ffffffffffffffffffffffffffffffffffffffff61085c613ab0565b610864614baf565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000007fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b6005416177fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b60055604051908152a180f35b506108e136613b3c565b949695969390939291923033036108fc57610461969761460b565b6004877f14d4a4e8000000000000000000000000000000000000000000000000000000008152fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397578061095d613ab0565b610965614baf565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690813b15610a1a5773ffffffffffffffffffffffffffffffffffffffff602484928360405195869485937fca5eb5e10000000000000000000000000000000000000000000000000000000085521660048401525af18015610a0f576109fe5750f35b81610a0891613c7a565b6103975780f35b6040513d84823e3d90fd5b5050fd5b5060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359067ffffffffffffffff8211610397578160040160e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8436030112610dda5760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc360112610dda57610abe613af6565b92610ac7614484565b50610ad0613fcc565b50610b2b6064604483013592013591610ae884613fe4565b50610af16152ad565b610afb8133615300565b610b267f00000000000000000000000000000000000000000000000000000000000000008092614f74565b614f61565b9080821061107d57508015611055576040517f9dc29fac00000000000000000000000000000000000000000000000000000000815233600482015260248101829052602081604481877f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff165af190811561104a57849161101b575b5015610ff357610bcb8183614c33565b610bd484613fe4565b9060405190610be282613bdd565b602435825260208201916044358352610bf9614484565b505193843403610fc757825180610df1575b5091839160809593610c20610c829b966145a3565b925115159263ffffffff60405195610c3787613c26565b168552602085015260408401526060830152848201526040518098819482937f2637a45000000000000000000000000000000000000000000000000000000000845260048401614e8f565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1928315610de5578093610d6c575b5060c0935060405190610cdd82613bdd565b8082526020820192818452610cf3855191613fe4565b9163ffffffff6040519316835280602084015260408301527f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a60603393a3602060408051948051865267ffffffffffffffff838201511683870152015180516040860152015160608401525160808301525160a0820152f35b90925060803d608011610dde575b610d848186613c7a565b840193608081860312610dda5760405191610d9e83613c5e565b8151835260208201519067ffffffffffffffff821682036103975750602083015260c094610dce91604001614e67565b6040820152915f610ccb565b5080fd5b503d610d7a565b604051903d90823e3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166040517fe4fe1d94000000000000000000000000000000000000000000000000000000008152602081600481855afa8015610fbc578b90610f55575b73ffffffffffffffffffffffffffffffffffffffff915016918215610f2d576020918b9160405190848201927f23b872dd0000000000000000000000000000000000000000000000000000000084523360248401526044830152606482015260648152610ed2608482613c7a565b519082855af115610f225788513d610f195750803b155b15610c0b577f5274afe7000000000000000000000000000000000000000000000000000000008952600452602488fd5b60011415610ee9565b6040513d8a823e3d90fd5b60048b7f5373352a000000000000000000000000000000000000000000000000000000008152fd5b506020813d602011610fb4575b81610f6f60209383613c7a565b81010312610fb0575173ffffffffffffffffffffffffffffffffffffffff81168103610fb05773ffffffffffffffffffffffffffffffffffffffff90610e64565b8a80fd5b3d9150610f62565b6040513d8d823e3d90fd5b6024887f9f70412000000000000000000000000000000000000000000000000000000000815234600452fd5b6004837f6f16aafc000000000000000000000000000000000000000000000000000000008152fd5b61103d915060203d602011611043575b6110358183613c7a565b810190614c1b565b5f610bbb565b503d61102b565b6040513d86823e3d90fd5b6004837f1f2a2005000000000000000000000000000000000000000000000000000000008152fd5b83906044927f71c4efed000000000000000000000000000000000000000000000000000000008352600452602452fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760ff604060209260043581527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00084522054166040519015158152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757611151613e52565b50604061115c6140e1565b82519182526020820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0008152f35b5060207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda5761120c903690600401613f25565b90827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec182360301905b838110156113f657848160051b84013583811215610dda5761129790850161125c81613fe4565b602082013592839163ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f2090565b54036113eb576112ab6101008201826141f7565b909160e08101359273ffffffffffffffffffffffffffffffffffffffff84168094036113e7576112df6101208301836141f7565b939091303b156113e357604051967fd045a0dc00000000000000000000000000000000000000000000000000000000885263ffffffff61131e86613e65565b166004890152602488015260408401359167ffffffffffffffff83168093036113df5788968896879561137387956113a89560c098604489015260a08b0135606489015260e0608489015260e4880191614248565b9260a48601527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8584030160c4860152614248565b03920135305af18015610a0f576113c6575b50506001905b01611235565b816113d091613c7a565b6113db57845f6113ba565b8480fd5b8880fd5b8780fd5b8580fd5b5050506001906113c0565b846040517f8e9e70990000000000000000000000000000000000000000000000000000000081528181600481335afa908115610a0f578291611472575b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152602060048201528061146e6024820185613a3f565b0390fd5b90503d8083833e6114838183613c7a565b8101906020818303126114f35780519067ffffffffffffffff82116114ef570181601f820112156114f3578051906114ba82613cbb565b926114c86040519485613c7a565b828452602083830101116114ef578161146e949260208093018386015e8301015282611433565b8380fd5b8280fd5b50346103975760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761152f613e52565b611537613f14565b916044359067ffffffffffffffff8211610397576107e86107d485856115603660048801613a82565b929091614286565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206115d96115a5613e52565b63ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f205490565b604051908152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda57611631903690600401613f25565b611639614baf565b825b818110611796575060405191816020840160208552526040830160408360051b850101928286907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1813603015b8383106116b957887fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b6748989038aa180f35b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088820301865286358281121561179257830163ffffffff61170082613e65565b168252602081013561ffff8116809103610fb057602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe182360301811215610fb057016020813591019067ffffffffffffffff8111610fb0578036038213610fb057611784602092839260608681604060019901520191614248565b980196019493019190611688565b8980fd5b9291906117ba6117b46117aa8684866141b7565b60408101906141f7565b9061500c565b6117c86117aa8583856141b7565b63ffffffff6117e36117de8886889a969a6141b7565b613fe4565b1685527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205260408520602061181b8486886141b7565b013561ffff811681036119cd5761ffff165f5260205260405f209067ffffffffffffffff81116119a05761184f8254614166565b601f811161195b575b508596601f82116001146118b757869782916001969798926118ac575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82861b9260031b1c19161790555b0161163b565b013590505f80611875565b82875260208720907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316885b81811061194357509060019697989984889594931061190b575b505050811b0190556118a6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88560031b161c199101351690555f80806118fe565b99926020600181928686013581550194019a016118e4565b82875260208720601f830160051c81019160208410611996575b601f0160051c01905b81811061198b5750611858565b87815560010161197e565b9091508190611975565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b8680fd5b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b6005416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613f56565b614091565b60405191829182613e03565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602090604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f00000000000000000000000000000000000000000000000000000000000000008152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405160068152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613f56565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757611cb361044f613f91565b611cbb6152ad565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005416177fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b5034610397577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160a08112610dda576060136103975760643567ffffffffffffffff8111610dda57611da9903690600401613a82565b50506020611db5613b19565b6040519073ffffffffffffffffffffffffffffffffffffffff309116148152f35b5034610397577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160808112610dda576040136103975760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc36011261039757611e4361044f613f56565b6040516060611e528183613c7a565b600282526040835b81811061205e575050604051611e6f81613c5e565b83815260043560208201526024356040820152611e8b83613ff5565b52611e9582613ff5565b50604051611ea281613c5e565b6001815260443560208201526064356040820152611ebf8361402f565b52611ec98261402f565b50825b8251841015611fda5763ffffffff611ee4858561403f565b51511681527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052604081209363ffffffff611f21828661403f565b51511682527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad70060205260408220948554611f6c6001880191825460028a01549060038b015492614fab565b5084611fad57600194959697554290556020611f88838861403f565b510151600282015560036040611f9e848961403f565b51015191015501929190611ecc565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b91604051916020830160208452825180915260206040850193019185905b82821061202957867fe888347665897e637801f36c5129f510657276178c89022bc5fa0246dbc19de187870388a180f35b909192936020826001926040885163ffffffff8151168352848101518584015201516040820152019501920190929192611ff8565b60209061206d95939495614148565b8282880101520193929193611e5a565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576104616120b8613ab0565b6120c361044f613e85565b61045c613f56565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613f91565b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602090612143613e52565b50604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757608090612186613fcc565b5061218f613fcc565b508080527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020526040812060408051926121c984613c42565b82548452600183015460208501526060600360028501549484870195865201549401938452600181527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad70060205220906040519061222582613c42565b8254825260018301546020830152606060036002850154946040850195865201549201918252519251916040519361225c85613bdd565b845260208401928352519051916040519161227683613bdd565b82526020820192835260405193518452516020840152516040830152516060820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576122d1614baf565b8073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197602073ffffffffffffffffffffffffffffffffffffffff6123e6613ab0565b6123ee614baf565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000007f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c005416177f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c0055604051908152a180f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda5760209173ffffffffffffffffffffffffffffffffffffffff6124de6124cf6124f4943690600401613ef6565b6124d7613ad3565b9350614053565b9116906001915f520160205260405f2054151590565b6040519015158152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461612539613ab0565b61254461044f613e85565b610795613f91565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613e85565b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda576125d9903690600401613f25565b906125e2613e76565b906125ee61044f613f56565b839115159260ff8416925b81811015612663576001908060051b84013587527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00060205260408720857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055016125f9565b5091509160405191604083528060408401527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116113db577fd963410eae89cc9a3cb39abd887724151decffcf59946d196742dbcc873e296893606092849260051b80928585013760208301528101030190a180f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166040519015158152f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206127e3613e52565b61281d6024359163ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f2090565b5414604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035416604051908152f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576128d0613e52565b63ffffffff6128dd613f14565b911682527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205261ffff6040832091165f5260205260405f2090604051918181549161292983614166565b80865292600181169081156129925750600114612951575b6107e8856107d481870382613c7a565b815260208120939250905b808210612978575090915081016020016107d4826107e8612941565b91926001816020925483858801015201910190929161295c565b8695506107e8969350602092506107d49491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b8201019293612941565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757606090612a14614148565b5060405190612a2282613c5e565b6001825260406020830192828452019081526040519160018352516020830152516040820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576020604051308152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604061115c6140e1565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc0008152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761115c606060408360018295527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052208351612b8181613c42565b81548082526001830154918260208201526003600285015494858984015201549485910152614fab565b503461039757612bba36613d48565b90612bc661044f613f56565b805b8251811015612c0c57600190612c06612bdf613cf5565b73ffffffffffffffffffffffffffffffffffffffff612bfe848861403f565b511690614b4a565b01612bc8565b5080f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359067ffffffffffffffff8211610397576107e8611af5611af03660048601613ef6565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613e85565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757612cda61044f613f91565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff811615612d76577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00167fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b6004827f8dfc202b000000000000000000000000000000000000000000000000000000008152fd5b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda57806004019060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82360301126114f357612e19613e76565b90612e22613fcc565b50612e666044610b26606484013593612e3a87613fe4565b507f00000000000000000000000000000000000000000000000000000000000000009283910135614f74565b90808210612f97575091604091612e8b612e83612efb9584614c33565b919093613fe4565b92612e94613fcc565b50612e9e846145a3565b63ffffffff865195612eaf87613c26565b1685526020850152848401526060830152151560808201528151809381927fddc28c58000000000000000000000000000000000000000000000000000000008352309060048401614e8f565b038173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165afa908115610a0f578291612f59575b60408260208251918051835201516020820152f35b905060403d604011612f90575b612f708183613c7a565b8101916040828403126103975750604091612f8a91614e67565b5f612f44565b503d612f66565b84906044927f71c4efed000000000000000000000000000000000000000000000000000000008352600452602452fd5b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b6040613022613e52565b63ffffffff60243591613033614baf565b16908185527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f900602052808386205582519182526020820152a180f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7008152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461613103613ab0565b61310e61044f613e85565b610795613e85565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405160018152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613cf5565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604080516001815260026020820152f35b5034610397576131dc36613d48565b906131e861044f613f56565b805b8251811015612c0c57600190613228613201613cf5565b73ffffffffffffffffffffffffffffffffffffffff613220848861403f565b511690614a64565b016131ea565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613cf5565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604080517f02e49c2c00000000000000000000000000000000000000000000000000000000815260016020820152f35b503461362e5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e576132ff613ab0565b613307613ad3565b906044359073ffffffffffffffffffffffffffffffffffffffff821680920361362e57613332613af6565b9261333b613b19565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c16159567ffffffffffffffff8416801590816136ea575b60011490816136e0575b1590816136d7575b506136af5773ffffffffffffffffffffffffffffffffffffffff9561341261348393868a60017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000006134999a16177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005561365a575b5061340a6151d3565b61053b6151d3565b61341a6151d3565b61342a613425613e85565b61526b565b6134438161343e613439613e85565b614053565b615546565b5061345461344f613e85565b614a48565b7f1cf4c2f10398d18e27c3336eeadbf9ce9571462b7cb30d5d9a4024580f208d215f80a3612544613425613f91565b61348e613425613cf5565b61078d613425613f56565b6134a16151d3565b6134a96151d3565b6134b16151d3565b6134b96151d3565b6134c16151d3565b6134c96151d3565b1680156136325773ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001690813b1561362e575f916024839260405194859384927fca5eb5e100000000000000000000000000000000000000000000000000000000845260048401525af180156136235761360e575b5061355b6151d3565b6135636151d3565b61356b6151d3565b6135736151d3565b61357a5780f35b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b61361b9192505f90613c7a565b5f905f613552565b6040513d5f823e3d90fd5b5f80fd5b7fb5863604000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00555f613401565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b9050155f61338d565b303b159150613385565b88915061337b565b3461362e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e57602060405160028152f35b61373436613b3c565b949390939291923373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016036137e05761378961378488613fe4565b6145a3565b9660208101358098036137a2576137a0975061460b565b005b63ffffffff6137b18992613fe4565b7fc26bebcc000000000000000000000000000000000000000000000000000000005f521660045260245260445ffd5b7f91ac5e4f000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b3461362e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e57602073ffffffffffffffffffffffffffffffffffffffff7f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c005416604051908152f35b3461362e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e5760043567ffffffffffffffff811161362e5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc823603011261362e576138f1613fcc565b506138fa613fcc565b5060405161390781613bdd565b5f8152602081019067ffffffffffffffff82526020926040519161392b8584613c7a565b5f83526139486044610b26606485013594612e3a81600401613fe4565b91808310613a105750936040519461395f86613bdd565b8286528186019283526040519460a0860191518652518286015260a06040860152835180915260c08501918060c08360051b8801019501925f905b8382106139b557885160608901528551608089015287870388f35b90919293958380613a01837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff408c600196030186526040838c518051845201519181858201520190613a3f565b9801920192019093929161399a565b827f71c4efed000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b9181601f8401121561362e5782359167ffffffffffffffff831161362e576020838186019501011161362e57565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6064359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6084359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc820160e0811261362e5760601361362e576004916064359160843567ffffffffffffffff811161362e5782613b9591600401613a82565b9290929160a43573ffffffffffffffffffffffffffffffffffffffff8116810361362e579160c4359067ffffffffffffffff821161362e57613bd991600401613a82565b9091565b6040810190811067ffffffffffffffff821117613bf957604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60a0810190811067ffffffffffffffff821117613bf957604052565b6080810190811067ffffffffffffffff821117613bf957604052565b6060810190811067ffffffffffffffff821117613bf957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117613bf957604052565b67ffffffffffffffff8111613bf957601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60405190613d04604083613c7a565b601682527f524154455f4c494d49545f4558454d50545f524f4c45000000000000000000006020830152565b67ffffffffffffffff8111613bf95760051b60200190565b60207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82011261362e576004359067ffffffffffffffff821161362e578060238301121561362e57816004013590613d9f82613d30565b92613dad6040519485613c7a565b8284526024602085019360051b82010191821161362e57602401915b818310613dd65750505090565b823573ffffffffffffffffffffffffffffffffffffffff8116810361362e57815260209283019201613dc9565b60206040818301928281528451809452019201905f5b818110613e265750505090565b825173ffffffffffffffffffffffffffffffffffffffff16845260209384019390920191600101613e19565b6004359063ffffffff8216820361362e57565b359063ffffffff8216820361362e57565b60243590811515820361362e57565b60405190613e94604083613c7a565b601b82527f4143434553535f434f4e54524f4c5f4d414e414745525f524f4c4500000000006020830152565b929192613ecc82613cbb565b91613eda6040519384613c7a565b82948184528183011161362e578281602093845f960137010152565b9080601f8301121561362e57816020613f1193359101613ec0565b90565b6024359061ffff8216820361362e57565b9181601f8401121561362e5782359167ffffffffffffffff831161362e576020808501948460051b01011161362e57565b60405190613f65604083613c7a565b601782527f524154455f4c494d49545f4d414e414745525f524f4c450000000000000000006020830152565b60405190613fa0604083613c7a565b600b82527f5041555345525f524f4c450000000000000000000000000000000000000000006020830152565b60405190613fd982613bdd565b5f6020838281520152565b3563ffffffff8116810361362e5790565b8051156140025760200190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b8051600110156140025760400190565b80518210156140025760209160051b010190565b60208091604051928184925191829101835e81017f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00281520301902090565b61409a90614053565b604051808260208294549384815201905f5260205f20925f5b8181106140c8575050613f1192500382613c7a565b84548352600194850194869450602090930192016140b3565b5f80527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052613bd9606060405f2060405161411d81613c42565b8154808252600183015491826020820152600360028501549485604084015201549485910152614fab565b6040519061415582613c5e565b5f6040838281528260208201520152565b90600182811c921680156141ad575b602083101461418057565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691614175565b91908110156140025760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa18136030182121561362e570190565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561362e570180359067ffffffffffffffff821161362e5760200191813603831361362e57565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b63ffffffff90949294165f527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205261ffff60405f2091165f5260205260405f206040515f91818154936142da85614166565b9283835260208301956001811690815f146144475750600114614403575b5061430592500382613c7a565b8051156143f55783156143ed57600284101561435b5750505061146e6040519283927f9a6d49cd000000000000000000000000000000000000000000000000000000008452602060048501526024840191614248565b61436a8486949695939561500c565b8160021161362e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe92613f11946040519687945180918587015e8401908382015f815260028785019201903701015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613c7a565b925050915090565b505091613f11913691613ec0565b90505f9291925260205f20905f915b81831061442b575050906020614305928201015f6142f8565b6020919350806001915483858801015201910190918392614412565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001687525061430593151560051b830160200191505f90506142f8565b6040519061449182613c5e565b815f81525f602082015260408051916144a983613bdd565b5f83525f60208401520152565b73ffffffffffffffffffffffffffffffffffffffff1680156145775773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b63ffffffff16805f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f20549081156145e0575090565b7ff6ff4fb7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9350935093508060201161362e5783359361469b67ffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff87169661468161467a6146508787615062565b7f000000000000000000000000000000000000000000000000000000000000000094859116614f61565b8989615074565b5067ffffffffffffffff6146958585615062565b16614f61565b916146a584613fe4565b5082866146b06152ad565b87156149d9575b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201526024810191909152602081806044810103815f73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000165af1908115613623575f916149ba575b501561499257602881116147a6575b50506040906147927fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c93613fe4565b9063ffffffff8351921682526020820152a3565b60408493929301359067ffffffffffffffff8216820361362e576147c985613fe4565b918160281161362e5760206148aa937fffffffff0000000000000000000000000000000000000000000000000000000061484e604c957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd860287fffffffffffffffff0000000000000000000000000000000000000000000000009b0191013691613ec0565b9160405198899560c01b168486015260e01b16602884015285602c8401528051918291018484015e81015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283613c7a565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803b1561362e5761493f5f939184926040519586809481937f7cb590120000000000000000000000000000000000000000000000000000000083528c60048401528b6024840152836044840152608060648401526084830190613a3f565b03925af18015613623577fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c9360409361479292614982575b509350819250614763565b5f61498c91613c7a565b5f614977565b7f07637bd8000000000000000000000000000000000000000000000000000000005f5260045ffd5b6149d3915060203d602011611043576110358183613c7a565b5f614754565b5061dead6146b7565b614a02336149ef83614053565b6001915f520160205260405f2054151590565b15614a0a5750565b61146e906040519182917fc13dd0f3000000000000000000000000000000000000000000000000000000008352602060048401526024830190613a3f565b602090604051918183925191829101835e81015f815203902090565b614aa0614a708261522a565b5f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2054151590565b15614b0c5773ffffffffffffffffffffffffffffffffffffffff90614ada90614ad4614acb82614053565b84861690615546565b50614a48565b9116907f1cf4c2f10398d18e27c3336eeadbf9ce9571462b7cb30d5d9a4024580f208d215f80a3565b8486169061559e565b61146e906040519182917f97270a52000000000000000000000000000000000000000000000000000000008352602060048401526024830190613a3f565b614b56614a708261522a565b15614b0c5773ffffffffffffffffffffffffffffffffffffffff90614b7a90614ba3565b9116907f1e5d48c75f77ab7fd581247d777530d4e8c18432289e14017ba995532f6ca1cf5f80a3565b614ad4614b0382614053565b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303614bef57565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b9081602091031261362e5751801515810361362e5790565b9091614d31614c686020840135947f000000000000000000000000000000000000000000000000000000000000000090614f74565b614c7f614c7860a08601866141f7565b3691613ec0565b8051158015969190614e1c57614d0c9160206068927fffffffffffffffff0000000000000000000000000000000000000000000000006040519687948486015260c01b1660408401523360488401528051918291018484015e81015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613c7a565b925b83945f14614e14576002905b611560614d2682613fe4565b9160808101906141f7565b9173ffffffffffffffffffffffffffffffffffffffff7f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c00541680614d73575050565b614dba602091614dea936040518095819482937f043a78eb000000000000000000000000000000000000000000000000000000008452604060048501526044840190613a3f565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc83820301602484015289613a3f565b03915afa801561362357614dfc575b50565b614df99060203d602011611043576110358183613c7a565b600190614d1a565b50907fffffffffffffffff0000000000000000000000000000000000000000000000009060405192602084015260c01b16604082015260288152614e61604882613c7a565b92614d0e565b919082604091031261362e57604051614e7f81613bdd565b6020808294805184520151910152565b9073ffffffffffffffffffffffffffffffffffffffff6020919493946040845263ffffffff81511660408501528281015160608501526080614f16614ee2604084015160a08489015260e0880190613a3f565b60608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160a0890152613a3f565b910151151560c08501529416910152565b91908203918211614f3457565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b81810292918115918404141715614f3457565b8115614f7e570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b919392614fc4614fbe614fd19342614f27565b86614f61565b9080156150035790614f74565b808211614ff45750505f915b82808211614feb5750505f90565b613f1191614f27565b614ffd91614f27565b91614fdd565b50600190614f74565b908060021161362e576003823560f01c03615025575050565b61146e6040519283927f9a6d49cd000000000000000000000000000000000000000000000000000000008452602060048501526024840191614248565b9060281161362e576020013560c01c90565b906150999073ffffffffffffffffffffffffffffffffffffffff6124de613439613cf5565b6151cf575f527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00060205260ff60405f205416614df95760015f527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020527f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc35580547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc35680547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc357547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc3585492959493615190939290614fab565b839193116151a7578201809211614f345755429055565b7fa74c1c5f000000000000000000000000000000000000000000000000000000005f5260045ffd5b5050565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561520257565b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b60208151910151906020811061523e575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060200360031b1b1690565b602081511161528557615280614df99161522a565b6153fd565b7f37d8d209000000000000000000000000000000000000000000000000000000005f5260045ffd5b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166152d857565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b6153249073ffffffffffffffffffffffffffffffffffffffff6124de613439613cf5565b614df9575f80527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020527fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b58f80547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b59080547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b591547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b5925492959493615190939290614fab565b8054821015614002575f5260205f2001905f90565b805f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2054155f14615541577f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0005468010000000000000000811015613bf9576154ec6154b78260018594017f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b000557f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0006153e8565b81939154907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060031b92831b921b19161790565b90557f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00054905f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2055600190565b505f90565b5f8281526001820160205260409020546155985780549068010000000000000000821015613bf957826155836154b78460018096018555846153e8565b90558054925f520160205260405f2055600190565b50505f90565b906001820191815f528260205260405f20548015155f146156ef577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101818111614f34578254907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201918211614f34578181036156ba575b5050508054801561568d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061565082826153e8565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82549160031b1b19169055555f526020525f6040812055600190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b6156da6156ca6154b793866153e8565b90549060031b1c928392866153e8565b90555f528360205260405f20555f8080615618565b505050505f9056f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0000000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b
Deployed Bytecode
0x60806040526004361015610011575f80fd5b5f5f3560e01c80630d35b4151461387c578063111ecdad1461380c57806313137d651461372b578063134d4f25146136f25780631459457a146132c7578063156a0d0f1461326857806315aefe3e1461322e57806316ee2ff6146131cd57806317442b701461318d5780631a3e6c57146131505780631f5e133414613116578063309e170f146130c8578063322922a21461306f5780633400288b14612fc75780633b6f743b14612d9e5780633f4ba83a14612ca0578063414c5f5014612c665780634592d72314612c10578063491bc11f14612bab5780634a2d53ff14612b155780634d0da67c14612abc5780634f39ceb414612a8357806352ae287914612a4a57806354fd4d50146129da5780635535d461146128985780635979e755146128275780635a0dfe4d146127a95780635c975abb146127495780635e280f11146126da5780636191cae01461258957806365cd0e491461254c5780636c11c21c146124fe5780636c9cd097146124615780636fc1b31e14612376578063715018a61461229a57806378f41c471461214c5780637d25a05e146121085780637f7712b4146120cb578063815170d31461207d578063820813b914611dd657806382413eac14611d515780638456cb5914611c79578063851937e114611c3f578063857749b014611c055780638da5cb5b14611b94578063963efcaa14611b3b5780639f68b96414611b01578063b027551514611ab3578063b731ea0a14611a42578063b97a2319146119d1578063b98bd070146115e1578063bb0b6a5314611568578063bc70b354146114f7578063bd815db0146111c1578063bebcab5614611168578063c272198d14611119578063c607cb7b146110ad578063c7c7f5b314610a1e578063ca5eb5e114610924578063d045a0dc146108d7578063d4243885146107ec578063e63ab1e91461079a578063ec6898e214610747578063f2bcac3d14610540578063f2fde38b146104f8578063f835b38d14610464578063f865af0814610409578063fc0c546a1461039a5763ff7bd03d14610311575f80fd5b346103975760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359063ffffffff8216820361039757602061038b8363ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f205490565b60405190602435148152f35b80fd5b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405173ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a168152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610444613ab0565b61045461044f613e85565b6149e2565b61045c613f91565b614b4a565b80f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761049c613ab0565b6104a761044f613e85565b3373ffffffffffffffffffffffffffffffffffffffff8216146104d0576104619061045c613e85565b6004827f373d7529000000000000000000000000000000000000000000000000000000008152fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610533613ab0565b61053b614baf565b6144b6565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b000549061059b82613d30565b916105a96040519384613c7a565b8083527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06105d682613d30565b01825b8181106107345750507f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00054825b828110610691575050506040519182916020830160208452825180915260408401602060408360051b870101940192905b82821061064657505050500390f35b91936020610681827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc060019597998495030186528851613a3f565b9601920192018594939192610637565b9293919281811015610707576001907f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0008652806020872001548660031b1c604051906020820152602081526106e7604082613c7a565b6106f1828661403f565b526106fc818561403f565b500193929193610606565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b60606020828701810191909152016105d9565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461610782613ab0565b61078d61044f613e85565b610795613f56565b614a64565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613f91565b604051918291602083526020830190613a3f565b0390f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c2427760602073ffffffffffffffffffffffffffffffffffffffff61085c613ab0565b610864614baf565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000007fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b6005416177fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b60055604051908152a180f35b506108e136613b3c565b949695969390939291923033036108fc57610461969761460b565b6004877f14d4a4e8000000000000000000000000000000000000000000000000000000008152fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397578061095d613ab0565b610965614baf565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b1690813b15610a1a5773ffffffffffffffffffffffffffffffffffffffff602484928360405195869485937fca5eb5e10000000000000000000000000000000000000000000000000000000085521660048401525af18015610a0f576109fe5750f35b81610a0891613c7a565b6103975780f35b6040513d84823e3d90fd5b5050fd5b5060807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359067ffffffffffffffff8211610397578160040160e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8436030112610dda5760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc360112610dda57610abe613af6565b92610ac7614484565b50610ad0613fcc565b50610b2b6064604483013592013591610ae884613fe4565b50610af16152ad565b610afb8133615300565b610b267f00000000000000000000000000000000000000000000000000000000000000018092614f74565b614f61565b9080821061107d57508015611055576040517f9dc29fac00000000000000000000000000000000000000000000000000000000815233600482015260248101829052602081604481877f00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a73ffffffffffffffffffffffffffffffffffffffff165af190811561104a57849161101b575b5015610ff357610bcb8183614c33565b610bd484613fe4565b9060405190610be282613bdd565b602435825260208201916044358352610bf9614484565b505193843403610fc757825180610df1575b5091839160809593610c20610c829b966145a3565b925115159263ffffffff60405195610c3787613c26565b168552602085015260408401526060830152848201526040518098819482937f2637a45000000000000000000000000000000000000000000000000000000000845260048401614e8f565b039173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b165af1928315610de5578093610d6c575b5060c0935060405190610cdd82613bdd565b8082526020820192818452610cf3855191613fe4565b9163ffffffff6040519316835280602084015260408301527f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a60603393a3602060408051948051865267ffffffffffffffff838201511683870152015180516040860152015160608401525160808301525160a0820152f35b90925060803d608011610dde575b610d848186613c7a565b840193608081860312610dda5760405191610d9e83613c5e565b8151835260208201519067ffffffffffffffff821682036103975750602083015260c094610dce91604001614e67565b6040820152915f610ccb565b5080fd5b503d610d7a565b604051903d90823e3d90fd5b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b166040517fe4fe1d94000000000000000000000000000000000000000000000000000000008152602081600481855afa8015610fbc578b90610f55575b73ffffffffffffffffffffffffffffffffffffffff915016918215610f2d576020918b9160405190848201927f23b872dd0000000000000000000000000000000000000000000000000000000084523360248401526044830152606482015260648152610ed2608482613c7a565b519082855af115610f225788513d610f195750803b155b15610c0b577f5274afe7000000000000000000000000000000000000000000000000000000008952600452602488fd5b60011415610ee9565b6040513d8a823e3d90fd5b60048b7f5373352a000000000000000000000000000000000000000000000000000000008152fd5b506020813d602011610fb4575b81610f6f60209383613c7a565b81010312610fb0575173ffffffffffffffffffffffffffffffffffffffff81168103610fb05773ffffffffffffffffffffffffffffffffffffffff90610e64565b8a80fd5b3d9150610f62565b6040513d8d823e3d90fd5b6024887f9f70412000000000000000000000000000000000000000000000000000000000815234600452fd5b6004837f6f16aafc000000000000000000000000000000000000000000000000000000008152fd5b61103d915060203d602011611043575b6110358183613c7a565b810190614c1b565b5f610bbb565b503d61102b565b6040513d86823e3d90fd5b6004837f1f2a2005000000000000000000000000000000000000000000000000000000008152fd5b83906044927f71c4efed000000000000000000000000000000000000000000000000000000008352600452602452fd5b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760ff604060209260043581527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00084522054166040519015158152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757611151613e52565b50604061115c6140e1565b82519182526020820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0008152f35b5060207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda5761120c903690600401613f25565b90827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec182360301905b838110156113f657848160051b84013583811215610dda5761129790850161125c81613fe4565b602082013592839163ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f2090565b54036113eb576112ab6101008201826141f7565b909160e08101359273ffffffffffffffffffffffffffffffffffffffff84168094036113e7576112df6101208301836141f7565b939091303b156113e357604051967fd045a0dc00000000000000000000000000000000000000000000000000000000885263ffffffff61131e86613e65565b166004890152602488015260408401359167ffffffffffffffff83168093036113df5788968896879561137387956113a89560c098604489015260a08b0135606489015260e0608489015260e4880191614248565b9260a48601527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8584030160c4860152614248565b03920135305af18015610a0f576113c6575b50506001905b01611235565b816113d091613c7a565b6113db57845f6113ba565b8480fd5b8880fd5b8780fd5b8580fd5b5050506001906113c0565b846040517f8e9e70990000000000000000000000000000000000000000000000000000000081528181600481335afa908115610a0f578291611472575b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152602060048201528061146e6024820185613a3f565b0390fd5b90503d8083833e6114838183613c7a565b8101906020818303126114f35780519067ffffffffffffffff82116114ef570181601f820112156114f3578051906114ba82613cbb565b926114c86040519485613c7a565b828452602083830101116114ef578161146e949260208093018386015e8301015282611433565b8380fd5b8280fd5b50346103975760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761152f613e52565b611537613f14565b916044359067ffffffffffffffff8211610397576107e86107d485856115603660048801613a82565b929091614286565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206115d96115a5613e52565b63ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f205490565b604051908152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda57611631903690600401613f25565b611639614baf565b825b818110611796575060405191816020840160208552526040830160408360051b850101928286907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1813603015b8383106116b957887fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b6748989038aa180f35b9091929394957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088820301865286358281121561179257830163ffffffff61170082613e65565b168252602081013561ffff8116809103610fb057602083015260408101357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe182360301811215610fb057016020813591019067ffffffffffffffff8111610fb0578036038213610fb057611784602092839260608681604060019901520191614248565b980196019493019190611688565b8980fd5b9291906117ba6117b46117aa8684866141b7565b60408101906141f7565b9061500c565b6117c86117aa8583856141b7565b63ffffffff6117e36117de8886889a969a6141b7565b613fe4565b1685527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205260408520602061181b8486886141b7565b013561ffff811681036119cd5761ffff165f5260205260405f209067ffffffffffffffff81116119a05761184f8254614166565b601f811161195b575b508596601f82116001146118b757869782916001969798926118ac575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82861b9260031b1c19161790555b0161163b565b013590505f80611875565b82875260208720907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08316885b81811061194357509060019697989984889594931061190b575b505050811b0190556118a6565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88560031b161c199101351690555f80806118fe565b99926020600181928686013581550194019a016118e4565b82875260208720601f830160051c81019160208410611996575b601f0160051c01905b81811061198b5750611858565b87815560010161197e565b9091508190611975565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b8680fd5b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7fefb041d771d6daaa55702fff6eb740d63ba559a75d2d1d3e151c78ff2480b6005416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613f56565b614091565b60405191829182613e03565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602090604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f00000000000000000000000000000000000000000000000000000000000000018152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405160068152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613f56565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757611cb361044f613f91565b611cbb6152ad565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff007fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005416177fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a180f35b5034610397577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160a08112610dda576060136103975760643567ffffffffffffffff8111610dda57611da9903690600401613a82565b50506020611db5613b19565b6040519073ffffffffffffffffffffffffffffffffffffffff309116148152f35b5034610397577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160808112610dda576040136103975760407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbc36011261039757611e4361044f613f56565b6040516060611e528183613c7a565b600282526040835b81811061205e575050604051611e6f81613c5e565b83815260043560208201526024356040820152611e8b83613ff5565b52611e9582613ff5565b50604051611ea281613c5e565b6001815260443560208201526064356040820152611ebf8361402f565b52611ec98261402f565b50825b8251841015611fda5763ffffffff611ee4858561403f565b51511681527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052604081209363ffffffff611f21828661403f565b51511682527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad70060205260408220948554611f6c6001880191825460028a01549060038b015492614fab565b5084611fad57600194959697554290556020611f88838861403f565b510151600282015560036040611f9e848961403f565b51015191015501929190611ecc565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b91604051916020830160208452825180915260206040850193019185905b82821061202957867fe888347665897e637801f36c5129f510657276178c89022bc5fa0246dbc19de187870388a180f35b909192936020826001926040885163ffffffff8151168352848101518584015201516040820152019501920190929192611ff8565b60209061206d95939495614148565b8282880101520193929193611e5a565b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576104616120b8613ab0565b6120c361044f613e85565b61045c613f56565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613f91565b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602090612143613e52565b50604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757608090612186613fcc565b5061218f613fcc565b508080527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020526040812060408051926121c984613c42565b82548452600183015460208501526060600360028501549484870195865201549401938452600181527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad70060205220906040519061222582613c42565b8254825260018301546020830152606060036002850154946040850195865201549201918252519251916040519361225c85613bdd565b845260208401928352519051916040519161227683613bdd565b82526020820192835260405193518452516020840152516040830152516060820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576122d1614baf565b8073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197602073ffffffffffffffffffffffffffffffffffffffff6123e6613ab0565b6123ee614baf565b16807fffffffffffffffffffffffff00000000000000000000000000000000000000007f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c005416177f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c0055604051908152a180f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda5760209173ffffffffffffffffffffffffffffffffffffffff6124de6124cf6124f4943690600401613ef6565b6124d7613ad3565b9350614053565b9116906001915f520160205260405f2054151590565b6040519015158152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461612539613ab0565b61254461044f613e85565b610795613f91565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613e85565b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda576125d9903690600401613f25565b906125e2613e76565b906125ee61044f613f56565b839115159260ff8416925b81811015612663576001908060051b84013587527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00060205260408720857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055016125f9565b5091509160405191604083528060408401527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81116113db577fd963410eae89cc9a3cb39abd887724151decffcf59946d196742dbcc873e296893606092849260051b80928585013760208301528101030190a180f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b168152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166040519015158152f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206127e3613e52565b61281d6024359163ffffffff165f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f2090565b5414604051908152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602073ffffffffffffffffffffffffffffffffffffffff7fb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d61035416604051908152f35b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576128d0613e52565b63ffffffff6128dd613f14565b911682527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205261ffff6040832091165f5260205260405f2090604051918181549161292983614166565b80865292600181169081156129925750600114612951575b6107e8856107d481870382613c7a565b815260208120939250905b808210612978575090915081016020016107d4826107e8612941565b91926001816020925483858801015201910190929161295c565b8695506107e8969350602092506107d49491507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001682840152151560051b8201019293612941565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757606090612a14614148565b5060405190612a2282613c5e565b6001825260406020830192828452019081526040519160018352516020830152516040820152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576020604051308152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604061115c6140e1565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc0008152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975761115c606060408360018295527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052208351612b8181613c42565b81548082526001830154918260208201526003600285015494858984015201549485910152614fab565b503461039757612bba36613d48565b90612bc661044f613f56565b805b8251811015612c0c57600190612c06612bdf613cf5565b73ffffffffffffffffffffffffffffffffffffffff612bfe848861403f565b511690614b4a565b01612bc8565b5080f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576004359067ffffffffffffffff8211610397576107e8611af5611af03660048601613ef6565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613e85565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757612cda61044f613f91565b7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f033005460ff811615612d76577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00167fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a180f35b6004827f8dfc202b000000000000000000000000000000000000000000000000000000008152fd5b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760043567ffffffffffffffff8111610dda57806004019060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82360301126114f357612e19613e76565b90612e22613fcc565b50612e666044610b26606484013593612e3a87613fe4565b507f00000000000000000000000000000000000000000000000000000000000000019283910135614f74565b90808210612f97575091604091612e8b612e83612efb9584614c33565b919093613fe4565b92612e94613fcc565b50612e9e846145a3565b63ffffffff865195612eaf87613c26565b1685526020850152848401526060830152151560808201528151809381927fddc28c58000000000000000000000000000000000000000000000000000000008352309060048401614e8f565b038173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b165afa908115610a0f578291612f59575b60408260208251918051835201516020820152f35b905060403d604011612f90575b612f708183613c7a565b8101916040828403126103975750604091612f8a91614e67565b5f612f44565b503d612f66565b84906044927f71c4efed000000000000000000000000000000000000000000000000000000008352600452602452fd5b50346103975760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397577f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b6040613022613e52565b63ffffffff60243591613033614baf565b16908185527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f900602052808386205582519182526020820152a180f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103975760206040517fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7008152f35b50346103975760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757610461613103613ab0565b61310e61044f613e85565b610795613e85565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757602060405160018152f35b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e8611af5611af0613cf5565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604080516001815260026020820152f35b5034610397576131dc36613d48565b906131e861044f613f56565b805b8251811015612c0c57600190613228613201613cf5565b73ffffffffffffffffffffffffffffffffffffffff613220848861403f565b511690614a64565b016131ea565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610397576107e86107d4613cf5565b503461039757807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039757604080517f02e49c2c00000000000000000000000000000000000000000000000000000000815260016020820152f35b503461362e5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e576132ff613ab0565b613307613ad3565b906044359073ffffffffffffffffffffffffffffffffffffffff821680920361362e57613332613af6565b9261333b613b19565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549160ff8360401c16159567ffffffffffffffff8416801590816136ea575b60011490816136e0575b1590816136d7575b506136af5773ffffffffffffffffffffffffffffffffffffffff9561341261348393868a60017fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000006134999a16177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005561365a575b5061340a6151d3565b61053b6151d3565b61341a6151d3565b61342a613425613e85565b61526b565b6134438161343e613439613e85565b614053565b615546565b5061345461344f613e85565b614a48565b7f1cf4c2f10398d18e27c3336eeadbf9ce9571462b7cb30d5d9a4024580f208d215f80a3612544613425613f91565b61348e613425613cf5565b61078d613425613f56565b6134a16151d3565b6134a96151d3565b6134b16151d3565b6134b96151d3565b6134c16151d3565b6134c96151d3565b1680156136325773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b1690813b1561362e575f916024839260405194859384927fca5eb5e100000000000000000000000000000000000000000000000000000000845260048401525af180156136235761360e575b5061355b6151d3565b6135636151d3565b61356b6151d3565b6135736151d3565b61357a5780f35b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a180f35b61361b9192505f90613c7a565b5f905f613552565b6040513d5f823e3d90fd5b5f80fd5b7fb5863604000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00555f613401565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b9050155f61338d565b303b159150613385565b88915061337b565b3461362e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e57602060405160028152f35b61373436613b3c565b949390939291923373ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b16036137e05761378961378488613fe4565b6145a3565b9660208101358098036137a2576137a0975061460b565b005b63ffffffff6137b18992613fe4565b7fc26bebcc000000000000000000000000000000000000000000000000000000005f521660045260245260445ffd5b7f91ac5e4f000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b3461362e575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e57602073ffffffffffffffffffffffffffffffffffffffff7f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c005416604051908152f35b3461362e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261362e5760043567ffffffffffffffff811161362e5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc823603011261362e576138f1613fcc565b506138fa613fcc565b5060405161390781613bdd565b5f8152602081019067ffffffffffffffff82526020926040519161392b8584613c7a565b5f83526139486044610b26606485013594612e3a81600401613fe4565b91808310613a105750936040519461395f86613bdd565b8286528186019283526040519460a0860191518652518286015260a06040860152835180915260c08501918060c08360051b8801019501925f905b8382106139b557885160608901528551608089015287870388f35b90919293958380613a01837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff408c600196030186526040838c518051845201519181858201520190613a3f565b9801920192019093929161399a565b827f71c4efed000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b9181601f8401121561362e5782359167ffffffffffffffff831161362e576020838186019501011161362e57565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6064359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b6084359073ffffffffffffffffffffffffffffffffffffffff8216820361362e57565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc820160e0811261362e5760601361362e576004916064359160843567ffffffffffffffff811161362e5782613b9591600401613a82565b9290929160a43573ffffffffffffffffffffffffffffffffffffffff8116810361362e579160c4359067ffffffffffffffff821161362e57613bd991600401613a82565b9091565b6040810190811067ffffffffffffffff821117613bf957604052565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b60a0810190811067ffffffffffffffff821117613bf957604052565b6080810190811067ffffffffffffffff821117613bf957604052565b6060810190811067ffffffffffffffff821117613bf957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117613bf957604052565b67ffffffffffffffff8111613bf957601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60405190613d04604083613c7a565b601682527f524154455f4c494d49545f4558454d50545f524f4c45000000000000000000006020830152565b67ffffffffffffffff8111613bf95760051b60200190565b60207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc82011261362e576004359067ffffffffffffffff821161362e578060238301121561362e57816004013590613d9f82613d30565b92613dad6040519485613c7a565b8284526024602085019360051b82010191821161362e57602401915b818310613dd65750505090565b823573ffffffffffffffffffffffffffffffffffffffff8116810361362e57815260209283019201613dc9565b60206040818301928281528451809452019201905f5b818110613e265750505090565b825173ffffffffffffffffffffffffffffffffffffffff16845260209384019390920191600101613e19565b6004359063ffffffff8216820361362e57565b359063ffffffff8216820361362e57565b60243590811515820361362e57565b60405190613e94604083613c7a565b601b82527f4143434553535f434f4e54524f4c5f4d414e414745525f524f4c4500000000006020830152565b929192613ecc82613cbb565b91613eda6040519384613c7a565b82948184528183011161362e578281602093845f960137010152565b9080601f8301121561362e57816020613f1193359101613ec0565b90565b6024359061ffff8216820361362e57565b9181601f8401121561362e5782359167ffffffffffffffff831161362e576020808501948460051b01011161362e57565b60405190613f65604083613c7a565b601782527f524154455f4c494d49545f4d414e414745525f524f4c450000000000000000006020830152565b60405190613fa0604083613c7a565b600b82527f5041555345525f524f4c450000000000000000000000000000000000000000006020830152565b60405190613fd982613bdd565b5f6020838281520152565b3563ffffffff8116810361362e5790565b8051156140025760200190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b8051600110156140025760400190565b80518210156140025760209160051b010190565b60208091604051928184925191829101835e81017f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00281520301902090565b61409a90614053565b604051808260208294549384815201905f5260205f20925f5b8181106140c8575050613f1192500382613c7a565b84548352600194850194869450602090930192016140b3565b5f80527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad700602052613bd9606060405f2060405161411d81613c42565b8154808252600183015491826020820152600360028501549485604084015201549485910152614fab565b6040519061415582613c5e565b5f6040838281528260208201520152565b90600182811c921680156141ad575b602083101461418057565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691614175565b91908110156140025760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa18136030182121561362e570190565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561362e570180359067ffffffffffffffff821161362e5760200191813603831361362e57565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b63ffffffff90949294165f527f8d2bda5d9f6ffb5796910376005392955773acee5548d0fcdb10e7c264ea000060205261ffff60405f2091165f5260205260405f206040515f91818154936142da85614166565b9283835260208301956001811690815f146144475750600114614403575b5061430592500382613c7a565b8051156143f55783156143ed57600284101561435b5750505061146e6040519283927f9a6d49cd000000000000000000000000000000000000000000000000000000008452602060048501526024840191614248565b61436a8486949695939561500c565b8160021161362e5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe92613f11946040519687945180918587015e8401908382015f815260028785019201903701015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613c7a565b925050915090565b505091613f11913691613ec0565b90505f9291925260205f20905f915b81831061442b575050906020614305928201015f6142f8565b6020919350806001915483858801015201910190918392614412565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001687525061430593151560051b830160200191505f90506142f8565b6040519061449182613c5e565b815f81525f602082015260408051916144a983613bdd565b5f83525f60208401520152565b73ffffffffffffffffffffffffffffffffffffffff1680156145775773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b7f1e4fbdf7000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b63ffffffff16805f527f72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f90060205260405f20549081156145e0575090565b7ff6ff4fb7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9350935093508060201161362e5783359361469b67ffffffffffffffff73ffffffffffffffffffffffffffffffffffffffff87169661468161467a6146508787615062565b7f000000000000000000000000000000000000000000000000000000000000000194859116614f61565b8989615074565b5067ffffffffffffffff6146958585615062565b16614f61565b916146a584613fe4565b5082866146b06152ad565b87156149d9575b6040517f40c10f1900000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911660048201526024810191909152602081806044810103815f73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a165af1908115613623575f916149ba575b501561499257602881116147a6575b50506040906147927fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c93613fe4565b9063ffffffff8351921682526020820152a3565b60408493929301359067ffffffffffffffff8216820361362e576147c985613fe4565b918160281161362e5760206148aa937fffffffff0000000000000000000000000000000000000000000000000000000061484e604c957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd860287fffffffffffffffff0000000000000000000000000000000000000000000000009b0191013691613ec0565b9160405198899560c01b168486015260e01b16602884015285602c8401528051918291018484015e81015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101845283613c7a565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b16803b1561362e5761493f5f939184926040519586809481937f7cb590120000000000000000000000000000000000000000000000000000000083528c60048401528b6024840152836044840152608060648401526084830190613a3f565b03925af18015613623577fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c9360409361479292614982575b509350819250614763565b5f61498c91613c7a565b5f614977565b7f07637bd8000000000000000000000000000000000000000000000000000000005f5260045ffd5b6149d3915060203d602011611043576110358183613c7a565b5f614754565b5061dead6146b7565b614a02336149ef83614053565b6001915f520160205260405f2054151590565b15614a0a5750565b61146e906040519182917fc13dd0f3000000000000000000000000000000000000000000000000000000008352602060048401526024830190613a3f565b602090604051918183925191829101835e81015f815203902090565b614aa0614a708261522a565b5f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2054151590565b15614b0c5773ffffffffffffffffffffffffffffffffffffffff90614ada90614ad4614acb82614053565b84861690615546565b50614a48565b9116907f1cf4c2f10398d18e27c3336eeadbf9ce9571462b7cb30d5d9a4024580f208d215f80a3565b8486169061559e565b61146e906040519182917f97270a52000000000000000000000000000000000000000000000000000000008352602060048401526024830190613a3f565b614b56614a708261522a565b15614b0c5773ffffffffffffffffffffffffffffffffffffffff90614b7a90614ba3565b9116907f1e5d48c75f77ab7fd581247d777530d4e8c18432289e14017ba995532f6ca1cf5f80a3565b614ad4614b0382614053565b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303614bef57565b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b9081602091031261362e5751801515810361362e5790565b9091614d31614c686020840135947f000000000000000000000000000000000000000000000000000000000000000190614f74565b614c7f614c7860a08601866141f7565b3691613ec0565b8051158015969190614e1c57614d0c9160206068927fffffffffffffffff0000000000000000000000000000000000000000000000006040519687948486015260c01b1660408401523360488401528051918291018484015e81015f8382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613c7a565b925b83945f14614e14576002905b611560614d2682613fe4565b9160808101906141f7565b9173ffffffffffffffffffffffffffffffffffffffff7f41db8a78b0206aba5c54bcbfc2bda0d84082a84eb88e680379a57b9e9f653c00541680614d73575050565b614dba602091614dea936040518095819482937f043a78eb000000000000000000000000000000000000000000000000000000008452604060048501526044840190613a3f565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc83820301602484015289613a3f565b03915afa801561362357614dfc575b50565b614df99060203d602011611043576110358183613c7a565b600190614d1a565b50907fffffffffffffffff0000000000000000000000000000000000000000000000009060405192602084015260c01b16604082015260288152614e61604882613c7a565b92614d0e565b919082604091031261362e57604051614e7f81613bdd565b6020808294805184520151910152565b9073ffffffffffffffffffffffffffffffffffffffff6020919493946040845263ffffffff81511660408501528281015160608501526080614f16614ee2604084015160a08489015260e0880190613a3f565b60608401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08883030160a0890152613a3f565b910151151560c08501529416910152565b91908203918211614f3457565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b81810292918115918404141715614f3457565b8115614f7e570490565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b919392614fc4614fbe614fd19342614f27565b86614f61565b9080156150035790614f74565b808211614ff45750505f915b82808211614feb5750505f90565b613f1191614f27565b614ffd91614f27565b91614fdd565b50600190614f74565b908060021161362e576003823560f01c03615025575050565b61146e6040519283927f9a6d49cd000000000000000000000000000000000000000000000000000000008452602060048501526024840191614248565b9060281161362e576020013560c01c90565b906150999073ffffffffffffffffffffffffffffffffffffffff6124de613439613cf5565b6151cf575f527f46ebb48068c820dda32398d3319596a3dcd92b5dc11b8421a9249951c14bc00060205260ff60405f205416614df95760015f527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020527f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc35580547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc35680547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc357547f6ddb0d03daeb79fab4146ca840e7e71e2b8a7e3e69068f564365086bbd1bc3585492959493615190939290614fab565b839193116151a7578201809211614f345755429055565b7fa74c1c5f000000000000000000000000000000000000000000000000000000005f5260045ffd5b5050565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c161561520257565b7fd7e6bcf8000000000000000000000000000000000000000000000000000000005f5260045ffd5b60208151910151906020811061523e575090565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060200360031b1b1690565b602081511161528557615280614df99161522a565b6153fd565b7f37d8d209000000000000000000000000000000000000000000000000000000005f5260045ffd5b60ff7fcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f0330054166152d857565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b6153249073ffffffffffffffffffffffffffffffffffffffff6124de613439613cf5565b614df9575f80527fb390a551b3795ab56089ef548dc2e0b762359b0ccdaabe5301837c5aeecad7006020527fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b58f80547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b59080547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b591547fd19c0cfd252ebd0dba47e141414343a141f369b29ec8af425439baf42d79b5925492959493615190939290614fab565b8054821015614002575f5260205f2001905f90565b805f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2054155f14615541577f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0005468010000000000000000811015613bf9576154ec6154b78260018594017f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b000557f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b0006153e8565b81939154907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9060031b92831b921b19161790565b90557f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00054905f527f8f8de9240b3899c03a31968f466af060ab1c78464aa7ae14941c20fe7917b00160205260405f2055600190565b505f90565b5f8281526001820160205260409020546155985780549068010000000000000000821015613bf957826155836154b78460018096018555846153e8565b90558054925f520160205260405f2055600190565b50505f90565b906001820191815f528260205260405f20548015155f146156ef577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8101818111614f34578254907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8201918211614f34578181036156ba575b5050508054801561568d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061565082826153e8565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82549160031b1b19169055555f526020525f6040812055600190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603160045260245ffd5b6156da6156ca6154b793866153e8565b90549060031b1c928392866153e8565b90555f528360205260405f20555f8080615618565b505050505f9056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b
-----Decoded View---------------
Arg [0] : _token (address): 0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a
Arg [1] : _lzEndpoint (address): 0x6F475642a6e85809B1c36Fa62763669b1b48DD5B
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000000000000efe302beaa2b3e6e1b18d08d69a9012a
Arg [1] : 0000000000000000000000006f475642a6e85809b1c36fa62763669b1b48dd5b
Loading...
Loading
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.