文件 1 的 21:Address.sol
pragma solidity ^0.7.0;
library Address {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 2 的 21:Buffer.sol
pragma solidity ^0.7.0;
library Buffer {
struct buffer {
bytes buf;
uint capacity;
}
function init(buffer memory buf, uint capacity) internal pure returns (buffer memory) {
if (capacity % 32 != 0) {
capacity += 32 - (capacity % 32);
}
buf.capacity = capacity;
assembly {
let ptr := mload(0x40)
mstore(buf, ptr)
mstore(ptr, 0)
mstore(0x40, add(32, add(ptr, capacity)))
}
return buf;
}
function writeRawBytes(
buffer memory buf,
uint off,
bytes memory rawData,
uint offData,
uint len
) internal pure returns (buffer memory) {
if (off + len > buf.capacity) {
resize(buf, max(buf.capacity, len + off) * 2);
}
uint dest;
uint src;
assembly {
let bufptr := mload(buf)
let buflen := mload(bufptr)
dest := add(add(bufptr, 32), off)
if gt(add(len, off), buflen) {
mstore(bufptr, add(len, off))
}
src := add(rawData, offData)
}
for (; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
uint mask = 256 ** (32 - len) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
return buf;
}
function write(buffer memory buf, uint off, bytes memory data, uint len) internal pure returns (buffer memory) {
require(len <= data.length);
if (off + len > buf.capacity) {
resize(buf, max(buf.capacity, len + off) * 2);
}
uint dest;
uint src;
assembly {
let bufptr := mload(buf)
let buflen := mload(bufptr)
dest := add(add(bufptr, 32), off)
if gt(add(len, off), buflen) {
mstore(bufptr, add(len, off))
}
src := add(data, 32)
}
for (; len >= 32; len -= 32) {
assembly {
mstore(dest, mload(src))
}
dest += 32;
src += 32;
}
uint mask = 256 ** (32 - len) - 1;
assembly {
let srcpart := and(mload(src), not(mask))
let destpart := and(mload(dest), mask)
mstore(dest, or(destpart, srcpart))
}
return buf;
}
function append(buffer memory buf, bytes memory data) internal pure returns (buffer memory) {
return write(buf, buf.buf.length, data, data.length);
}
function resize(buffer memory buf, uint capacity) private pure {
bytes memory oldbuf = buf.buf;
init(buf, capacity);
append(buf, oldbuf);
}
function max(uint a, uint b) private pure returns (uint) {
if (a > b) {
return a;
}
return b;
}
}
文件 3 的 21:Context.sol
pragma solidity >=0.6.0 <0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 4 的 21:IERC20.sol
pragma solidity ^0.7.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 5 的 21:ILayerZeroEndpoint.sol
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
function send(
uint16 _dstChainId,
bytes calldata _destination,
bytes calldata _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
function receivePayload(
uint16 _srcChainId,
bytes calldata _srcAddress,
address _dstAddress,
uint64 _nonce,
uint _gasLimit,
bytes calldata _payload
) external;
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint nativeFee, uint zroFee);
function getChainId() external view returns (uint16);
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
function getSendLibraryAddress(address _userApplication) external view returns (address);
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
function isSendingPayload() external view returns (bool);
function isReceivingPayload() external view returns (bool);
function getConfig(
uint16 _version,
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
function getSendVersion(address _userApplication) external view returns (uint16);
function getReceiveVersion(address _userApplication) external view returns (uint16);
}
文件 6 的 21:ILayerZeroMessagingLibrary.sol
pragma solidity >=0.7.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroMessagingLibrary {
function send(
address _userApplication,
uint64 _lastNonce,
uint16 _chainId,
bytes calldata _destination,
bytes calldata _payload,
address payable refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
function estimateFees(
uint16 _chainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint nativeFee, uint zroFee);
function setConfig(uint16 _chainId, address _userApplication, uint _configType, bytes calldata _config) external;
function getConfig(
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
}
文件 7 的 21:ILayerZeroMessagingLibraryV2.sol
pragma solidity >=0.7.0;
import "./ILayerZeroUserApplicationConfig.sol";
import "./ILayerZeroMessagingLibrary.sol";
interface ILayerZeroMessagingLibraryV2 is ILayerZeroMessagingLibrary {
function getOutboundNonce(uint16 _chainId, bytes calldata _path) external view returns (uint64);
}
文件 8 的 21:ILayerZeroOracleV2.sol
pragma solidity >=0.7.0;
interface ILayerZeroOracleV2 {
function assignJob(
uint16 _dstChainId,
uint16 _outboundProofType,
uint64 _outboundBlockConfirmation,
address _userApplication
) external returns (uint price);
function getFee(
uint16 _dstChainId,
uint16 _outboundProofType,
uint64 _outboundBlockConfirmation,
address _userApplication
) external view returns (uint price);
function withdrawFee(address payable _to, uint _amount) external;
}
文件 9 的 21:ILayerZeroReceiver.sol
pragma solidity >=0.5.0;
interface ILayerZeroReceiver {
function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;
}
文件 10 的 21:ILayerZeroRelayerV2.sol
pragma solidity >=0.7.0;
interface ILayerZeroRelayerV2 {
function assignJob(
uint16 _dstChainId,
uint16 _outboundProofType,
address _userApplication,
uint _payloadSize,
bytes calldata _adapterParams
) external returns (uint price);
function getFee(
uint16 _dstChainId,
uint16 _outboundProofType,
address _userApplication,
uint _payloadSize,
bytes calldata _adapterParams
) external view returns (uint price);
function withdrawFee(address payable _to, uint _amount) external;
}
文件 11 的 21:ILayerZeroTreasury.sol
pragma solidity >=0.5.0;
interface ILayerZeroTreasury {
function getFees(bool payInZro, uint relayerFee, uint oracleFee) external view returns (uint);
}
文件 12 的 21:ILayerZeroUltraLightNodeV2.sol
pragma solidity >=0.7.0;
pragma abicoder v2;
interface ILayerZeroUltraLightNodeV2 {
function validateTransactionProof(
uint16 _srcChainId,
address _dstAddress,
uint _gasLimit,
bytes32 _lookupHash,
bytes32 _blockData,
bytes calldata _transactionProof
) external;
function updateHash(uint16 _srcChainId, bytes32 _lookupHash, uint _confirmations, bytes32 _blockData) external;
function withdrawNative(address payable _to, uint _amount) external;
function withdrawZRO(address _to, uint _amount) external;
function getAppConfig(
uint16 _remoteChainId,
address _userApplicationAddress
) external view returns (ApplicationConfiguration memory);
function accruedNativeFee(address _address) external view returns (uint);
struct ApplicationConfiguration {
uint16 inboundProofLibraryVersion;
uint64 inboundBlockConfirmations;
address relayer;
uint16 outboundProofType;
uint64 outboundBlockConfirmations;
address oracle;
}
event HashReceived(
uint16 indexed srcChainId,
address indexed oracle,
bytes32 lookupHash,
bytes32 blockData,
uint confirmations
);
event RelayerParams(bytes adapterParams, uint16 outboundProofType);
event Packet(bytes payload);
event InvalidDst(
uint16 indexed srcChainId,
bytes srcAddress,
address indexed dstAddress,
uint64 nonce,
bytes32 payloadHash
);
event PacketReceived(
uint16 indexed srcChainId,
bytes srcAddress,
address indexed dstAddress,
uint64 nonce,
bytes32 payloadHash
);
event AppConfigUpdated(address indexed userApplication, uint indexed configType, bytes newConfig);
event AddInboundProofLibraryForChain(uint16 indexed chainId, address lib);
event EnableSupportedOutboundProof(uint16 indexed chainId, uint16 proofType);
event SetChainAddressSize(uint16 indexed chainId, uint size);
event SetDefaultConfigForChainId(
uint16 indexed chainId,
uint16 inboundProofLib,
uint64 inboundBlockConfirm,
address relayer,
uint16 outboundProofType,
uint64 outboundBlockConfirm,
address oracle
);
event SetDefaultAdapterParamsForChainId(uint16 indexed chainId, uint16 indexed proofType, bytes adapterParams);
event SetLayerZeroToken(address indexed tokenAddress);
event SetRemoteUln(uint16 indexed chainId, bytes32 uln);
event SetTreasury(address indexed treasuryAddress);
event WithdrawZRO(address indexed msgSender, address indexed to, uint amount);
event WithdrawNative(address indexed msgSender, address indexed to, uint amount);
}
文件 13 的 21:ILayerZeroUserApplicationConfig.sol
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
function setSendVersion(uint16 _version) external;
function setReceiveVersion(uint16 _version) external;
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}
文件 14 的 21:ILayerZeroValidationLibrary.sol
pragma solidity >=0.7.0;
pragma abicoder v2;
import "../proof/utility/LayerZeroPacket.sol";
interface ILayerZeroValidationLibrary {
function validateProof(
bytes32 blockData,
bytes calldata _data,
uint _remoteAddressSize
) external returns (LayerZeroPacket.Packet memory packet);
}
文件 15 的 21:LayerZeroPacket.sol
pragma solidity 0.7.6;
import "./Buffer.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
library LayerZeroPacket {
using Buffer for Buffer.buffer;
using SafeMath for uint;
struct Packet {
uint16 srcChainId;
uint16 dstChainId;
uint64 nonce;
address dstAddress;
bytes srcAddress;
bytes32 ulnAddress;
bytes payload;
}
function getPacket(
bytes memory data,
uint16 srcChain,
uint sizeOfSrcAddress,
bytes32 ulnAddress
) internal pure returns (LayerZeroPacket.Packet memory) {
uint16 dstChainId;
address dstAddress;
uint size;
uint64 nonce;
assembly {
dstChainId := mload(add(data, 32))
size := mload(add(data, 96))
nonce := mload(add(data, 104))
dstAddress := mload(add(data, sub(add(128, sizeOfSrcAddress), 4)))
}
Buffer.buffer memory srcAddressBuffer;
srcAddressBuffer.init(sizeOfSrcAddress);
srcAddressBuffer.writeRawBytes(0, data, 136, sizeOfSrcAddress);
uint payloadSize = size.sub(28).sub(sizeOfSrcAddress);
Buffer.buffer memory payloadBuffer;
payloadBuffer.init(payloadSize);
payloadBuffer.writeRawBytes(0, data, sizeOfSrcAddress.add(156), payloadSize);
return
LayerZeroPacket.Packet(
srcChain,
dstChainId,
nonce,
dstAddress,
srcAddressBuffer.buf,
ulnAddress,
payloadBuffer.buf
);
}
function getPacketV2(
bytes memory data,
uint sizeOfSrcAddress,
bytes32 ulnAddress
) internal pure returns (LayerZeroPacket.Packet memory) {
uint256 realSize;
uint64 nonce;
uint16 srcChain;
uint16 dstChain;
address dstAddress;
assembly {
realSize := mload(add(data, 64))
nonce := mload(add(data, 72))
srcChain := mload(add(data, 74))
dstChain := mload(add(data, add(76, sizeOfSrcAddress)))
dstAddress := mload(add(data, add(96, sizeOfSrcAddress)))
}
require(srcChain != 0, "LayerZeroPacket: invalid packet");
Buffer.buffer memory srcAddressBuffer;
srcAddressBuffer.init(sizeOfSrcAddress);
srcAddressBuffer.writeRawBytes(0, data, 106, sizeOfSrcAddress);
uint nonPayloadSize = sizeOfSrcAddress.add(32);
uint payloadSize = realSize.sub(nonPayloadSize);
Buffer.buffer memory payloadBuffer;
payloadBuffer.init(payloadSize);
payloadBuffer.writeRawBytes(0, data, nonPayloadSize.add(96), payloadSize);
return
LayerZeroPacket.Packet(
srcChain,
dstChain,
nonce,
dstAddress,
srcAddressBuffer.buf,
ulnAddress,
payloadBuffer.buf
);
}
function getPacketV3(
bytes memory data,
uint sizeOfSrcAddress,
bytes32 ulnAddress
) internal pure returns (LayerZeroPacket.Packet memory) {
uint256 realSize = data.length;
uint nonPayloadSize = sizeOfSrcAddress.add(32);
require(realSize >= nonPayloadSize, "LayerZeroPacket: invalid packet");
uint payloadSize = realSize - nonPayloadSize;
uint64 nonce;
uint16 srcChain;
uint16 dstChain;
address dstAddress;
assembly {
nonce := mload(add(data, 8))
srcChain := mload(add(data, 10))
dstChain := mload(add(data, add(12, sizeOfSrcAddress)))
dstAddress := mload(add(data, add(32, sizeOfSrcAddress)))
}
require(srcChain != 0, "LayerZeroPacket: invalid packet");
Buffer.buffer memory srcAddressBuffer;
srcAddressBuffer.init(sizeOfSrcAddress);
srcAddressBuffer.writeRawBytes(0, data, 42, sizeOfSrcAddress);
Buffer.buffer memory payloadBuffer;
if (payloadSize > 0) {
payloadBuffer.init(payloadSize);
payloadBuffer.writeRawBytes(0, data, nonPayloadSize.add(32), payloadSize);
}
return
LayerZeroPacket.Packet(
srcChain,
dstChain,
nonce,
dstAddress,
srcAddressBuffer.buf,
ulnAddress,
payloadBuffer.buf
);
}
}
文件 16 的 21:NonceContract.sol
pragma solidity 0.7.6;
import "./interfaces/ILayerZeroEndpoint.sol";
contract NonceContract {
ILayerZeroEndpoint public immutable endpoint;
mapping(uint16 => mapping(bytes => uint64)) public outboundNonce;
constructor(address _endpoint) {
endpoint = ILayerZeroEndpoint(_endpoint);
}
function increment(uint16 _chainId, address _ua, bytes calldata _path) external returns (uint64) {
require(
endpoint.getSendLibraryAddress(_ua) == msg.sender,
"NonceContract: msg.sender is not valid sendlibrary"
);
return ++outboundNonce[_chainId][_path];
}
}
文件 17 的 21:Ownable.sol
pragma solidity ^0.7.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view virtual returns (address) {
return _owner;
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 18 的 21:ReentrancyGuard.sol
pragma solidity ^0.7.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
}
文件 19 的 21:SafeERC20.sol
pragma solidity ^0.7.0;
import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
文件 20 的 21:SafeMath.sol
pragma solidity ^0.7.0;
library SafeMath {
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
文件 21 的 21:UltraLightNodeV2.sol
pragma solidity 0.7.6;
pragma abicoder v2;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./interfaces/ILayerZeroValidationLibrary.sol";
import "./interfaces/ILayerZeroReceiver.sol";
import "./interfaces/ILayerZeroTreasury.sol";
import "./interfaces/ILayerZeroEndpoint.sol";
import "./interfaces/ILayerZeroMessagingLibraryV2.sol";
import "./interfaces/ILayerZeroOracleV2.sol";
import "./interfaces/ILayerZeroUltraLightNodeV2.sol";
import "./interfaces/ILayerZeroRelayerV2.sol";
import "./NonceContract.sol";
contract UltraLightNodeV2 is ILayerZeroMessagingLibraryV2, ILayerZeroUltraLightNodeV2, ReentrancyGuard, Ownable {
using SafeERC20 for IERC20;
using SafeMath for uint;
uint public constant CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION = 1;
uint public constant CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS = 2;
uint public constant CONFIG_TYPE_RELAYER = 3;
uint public constant CONFIG_TYPE_OUTBOUND_PROOF_TYPE = 4;
uint public constant CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS = 5;
uint public constant CONFIG_TYPE_ORACLE = 6;
IERC20 public layerZeroToken;
ILayerZeroTreasury public treasuryContract;
mapping(address => uint) public nativeFees;
uint public treasuryZROFees;
mapping(address => mapping(uint16 => ApplicationConfiguration)) public appConfig;
mapping(uint16 => ApplicationConfiguration) public defaultAppConfig;
mapping(uint16 => mapping(uint16 => bytes)) public defaultAdapterParams;
mapping(uint16 => mapping(uint16 => address)) public inboundProofLibrary;
mapping(uint16 => uint16) public maxInboundProofLibrary;
mapping(uint16 => mapping(uint16 => bool)) public supportedOutboundProof;
mapping(uint16 => uint) public chainAddressSizeMap;
mapping(address => mapping(uint16 => mapping(bytes32 => mapping(bytes32 => uint)))) public hashLookup;
mapping(uint16 => bytes32) public ulnLookup;
ILayerZeroEndpoint public immutable endpoint;
uint16 public immutable localChainId;
NonceContract public immutable nonceContract;
constructor(address _endpoint, address _nonceContract, uint16 _localChainId) {
require(_endpoint != address(0x0), "LayerZero: endpoint cannot be zero address");
require(_nonceContract != address(0x0), "LayerZero: nonceContract cannot be zero address");
ILayerZeroEndpoint lzEndpoint = ILayerZeroEndpoint(_endpoint);
localChainId = _localChainId;
endpoint = lzEndpoint;
nonceContract = NonceContract(_nonceContract);
}
modifier onlyEndpoint() {
require(address(endpoint) == msg.sender, "LayerZero: only endpoint");
_;
}
function validateTransactionProof(
uint16 _srcChainId,
address _dstAddress,
uint _gasLimit,
bytes32 _lookupHash,
bytes32 _blockData,
bytes calldata _transactionProof
) external override {
ApplicationConfiguration memory uaConfig = _getAppConfig(_srcChainId, _dstAddress);
require(uaConfig.relayer == msg.sender, "LayerZero: invalid relayer");
LayerZeroPacket.Packet memory _packet;
uint remoteAddressSize = chainAddressSizeMap[_srcChainId];
require(remoteAddressSize != 0, "LayerZero: incorrect remote address size");
{
uint storedConfirmations = hashLookup[uaConfig.oracle][_srcChainId][_lookupHash][_blockData];
require(
storedConfirmations > 0 && storedConfirmations >= uaConfig.inboundBlockConfirmations,
"LayerZero: not enough block confirmations"
);
address inboundProofLib = inboundProofLibrary[_srcChainId][uaConfig.inboundProofLibraryVersion];
_packet = ILayerZeroValidationLibrary(inboundProofLib).validateProof(
_blockData,
_transactionProof,
remoteAddressSize
);
}
require(
ulnLookup[_srcChainId] == _packet.ulnAddress && _packet.ulnAddress != bytes32(0),
"LayerZero: invalid _packet.ulnAddress"
);
require(_packet.srcChainId == _srcChainId, "LayerZero: invalid srcChain Id");
require(_packet.srcAddress.length == remoteAddressSize, "LayerZero: invalid srcAddress size");
require(_packet.dstChainId == localChainId, "LayerZero: invalid dstChain Id");
require(_packet.dstAddress == _dstAddress, "LayerZero: invalid dstAddress");
if (!_isContract(_dstAddress)) {
emit InvalidDst(
_packet.srcChainId,
_packet.srcAddress,
_packet.dstAddress,
_packet.nonce,
keccak256(_packet.payload)
);
return;
}
bytes memory pathData = abi.encodePacked(_packet.srcAddress, _packet.dstAddress);
emit PacketReceived(
_packet.srcChainId,
_packet.srcAddress,
_packet.dstAddress,
_packet.nonce,
keccak256(_packet.payload)
);
endpoint.receivePayload(_srcChainId, pathData, _dstAddress, _packet.nonce, _gasLimit, _packet.payload);
}
function send(
address _ua,
uint64,
uint16 _dstChainId,
bytes calldata _path,
bytes calldata _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable override onlyEndpoint {
address ua = _ua;
uint16 dstChainId = _dstChainId;
require(ulnLookup[dstChainId] != bytes32(0), "LayerZero: dstChainId does not exist");
bytes memory dstAddress;
uint64 nonce;
{
uint chainAddressSize = chainAddressSizeMap[dstChainId];
require(
chainAddressSize != 0 && _path.length == 20 + chainAddressSize,
"LayerZero: incorrect remote address size"
);
address srcInPath;
bytes memory path = _path;
assembly {
srcInPath := mload(add(add(path, 20), chainAddressSize))
}
require(ua == srcInPath, "LayerZero: wrong path data");
dstAddress = _path[0:chainAddressSize];
nonce = nonceContract.increment(dstChainId, ua, path);
}
bytes memory payload = _payload;
ApplicationConfiguration memory uaConfig = _getAppConfig(dstChainId, ua);
uint relayerFee = _handleRelayer(dstChainId, uaConfig, ua, payload.length, _adapterParams);
uint oracleFee = _handleOracle(dstChainId, uaConfig, ua);
uint nativeProtocolFee = _handleProtocolFee(relayerFee, oracleFee, ua, _zroPaymentAddress);
uint totalNativeFee = relayerFee.add(oracleFee).add(nativeProtocolFee);
require(totalNativeFee <= msg.value, "LayerZero: not enough native for fees");
uint amount = msg.value.sub(totalNativeFee);
if (amount > 0) {
(bool success, ) = _refundAddress.call{value: amount}("");
require(success, "LayerZero: failed to refund");
}
bytes memory encodedPayload = abi.encodePacked(nonce, localChainId, ua, dstChainId, dstAddress, payload);
emit Packet(encodedPayload);
}
function _handleRelayer(
uint16 _dstChainId,
ApplicationConfiguration memory _uaConfig,
address _ua,
uint _payloadSize,
bytes memory _adapterParams
) internal returns (uint relayerFee) {
if (_adapterParams.length == 0) {
_adapterParams = defaultAdapterParams[_dstChainId][_uaConfig.outboundProofType];
}
address relayerAddress = _uaConfig.relayer;
ILayerZeroRelayerV2 relayer = ILayerZeroRelayerV2(relayerAddress);
relayerFee = relayer.assignJob(_dstChainId, _uaConfig.outboundProofType, _ua, _payloadSize, _adapterParams);
_creditNativeFee(relayerAddress, relayerFee);
emit RelayerParams(_adapterParams, _uaConfig.outboundProofType);
}
function _handleOracle(
uint16 _dstChainId,
ApplicationConfiguration memory _uaConfig,
address _ua
) internal returns (uint oracleFee) {
address oracleAddress = _uaConfig.oracle;
oracleFee = ILayerZeroOracleV2(oracleAddress).assignJob(
_dstChainId,
_uaConfig.outboundProofType,
_uaConfig.outboundBlockConfirmations,
_ua
);
_creditNativeFee(oracleAddress, oracleFee);
}
function _handleProtocolFee(
uint _relayerFee,
uint _oracleFee,
address _ua,
address _zroPaymentAddress
) internal returns (uint protocolNativeFee) {
bool payInNative = _zroPaymentAddress == address(0x0) || address(layerZeroToken) == address(0x0);
uint protocolFee = treasuryContract.getFees(!payInNative, _relayerFee, _oracleFee);
if (protocolFee > 0) {
if (payInNative) {
address treasuryAddress = address(treasuryContract);
_creditNativeFee(treasuryAddress, protocolFee);
protocolNativeFee = protocolFee;
} else {
require(
_zroPaymentAddress == _ua || _zroPaymentAddress == tx.origin,
"LayerZero: must be paid by sender or origin"
);
layerZeroToken.safeTransferFrom(_zroPaymentAddress, address(this), protocolFee);
treasuryZROFees = treasuryZROFees.add(protocolFee);
}
}
}
function _creditNativeFee(address _receiver, uint _amount) internal {
nativeFees[_receiver] = nativeFees[_receiver].add(_amount);
}
function updateHash(
uint16 _srcChainId,
bytes32 _lookupHash,
uint _confirmations,
bytes32 _blockData
) external override {
uint storedConfirmations = hashLookup[msg.sender][_srcChainId][_lookupHash][_blockData];
require(
storedConfirmations < _confirmations,
"LayerZero: oracle data can only update if it has more confirmations"
);
hashLookup[msg.sender][_srcChainId][_lookupHash][_blockData] = _confirmations;
emit HashReceived(_srcChainId, msg.sender, _lookupHash, _blockData, _confirmations);
}
function getAppConfig(
uint16 _remoteChainId,
address _ua
) external view override returns (ApplicationConfiguration memory) {
return _getAppConfig(_remoteChainId, _ua);
}
function _getAppConfig(uint16 _remoteChainId, address _ua) internal view returns (ApplicationConfiguration memory) {
ApplicationConfiguration memory config = appConfig[_ua][_remoteChainId];
ApplicationConfiguration storage defaultConfig = defaultAppConfig[_remoteChainId];
if (config.inboundProofLibraryVersion == 0) {
config.inboundProofLibraryVersion = defaultConfig.inboundProofLibraryVersion;
}
if (config.inboundBlockConfirmations == 0) {
config.inboundBlockConfirmations = defaultConfig.inboundBlockConfirmations;
}
if (config.relayer == address(0x0)) {
config.relayer = defaultConfig.relayer;
}
if (config.outboundProofType == 0) {
config.outboundProofType = defaultConfig.outboundProofType;
}
if (config.outboundBlockConfirmations == 0) {
config.outboundBlockConfirmations = defaultConfig.outboundBlockConfirmations;
}
if (config.oracle == address(0x0)) {
config.oracle = defaultConfig.oracle;
}
return config;
}
function setConfig(
uint16 _remoteChainId,
address _ua,
uint _configType,
bytes calldata _config
) external override onlyEndpoint {
ApplicationConfiguration storage uaConfig = appConfig[_ua][_remoteChainId];
if (_configType == CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION) {
uint16 inboundProofLibraryVersion = abi.decode(_config, (uint16));
require(
inboundProofLibraryVersion <= maxInboundProofLibrary[_remoteChainId],
"LayerZero: invalid inbound proof library version"
);
uaConfig.inboundProofLibraryVersion = inboundProofLibraryVersion;
} else if (_configType == CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS) {
uint64 blockConfirmations = abi.decode(_config, (uint64));
uaConfig.inboundBlockConfirmations = blockConfirmations;
} else if (_configType == CONFIG_TYPE_RELAYER) {
address relayer = abi.decode(_config, (address));
uaConfig.relayer = relayer;
} else if (_configType == CONFIG_TYPE_OUTBOUND_PROOF_TYPE) {
uint16 outboundProofType = abi.decode(_config, (uint16));
require(
supportedOutboundProof[_remoteChainId][outboundProofType] || outboundProofType == 0,
"LayerZero: invalid outbound proof type"
);
uaConfig.outboundProofType = outboundProofType;
} else if (_configType == CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS) {
uint64 blockConfirmations = abi.decode(_config, (uint64));
uaConfig.outboundBlockConfirmations = blockConfirmations;
} else if (_configType == CONFIG_TYPE_ORACLE) {
address oracle = abi.decode(_config, (address));
uaConfig.oracle = oracle;
} else {
revert("LayerZero: Invalid config type");
}
emit AppConfigUpdated(_ua, _configType, _config);
}
function getConfig(
uint16 _remoteChainId,
address _ua,
uint _configType
) external view override returns (bytes memory) {
ApplicationConfiguration storage uaConfig = appConfig[_ua][_remoteChainId];
if (_configType == CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION) {
if (uaConfig.inboundProofLibraryVersion == 0) {
return abi.encode(defaultAppConfig[_remoteChainId].inboundProofLibraryVersion);
}
return abi.encode(uaConfig.inboundProofLibraryVersion);
} else if (_configType == CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS) {
if (uaConfig.inboundBlockConfirmations == 0) {
return abi.encode(defaultAppConfig[_remoteChainId].inboundBlockConfirmations);
}
return abi.encode(uaConfig.inboundBlockConfirmations);
} else if (_configType == CONFIG_TYPE_RELAYER) {
if (uaConfig.relayer == address(0x0)) {
return abi.encode(defaultAppConfig[_remoteChainId].relayer);
}
return abi.encode(uaConfig.relayer);
} else if (_configType == CONFIG_TYPE_OUTBOUND_PROOF_TYPE) {
if (uaConfig.outboundProofType == 0) {
return abi.encode(defaultAppConfig[_remoteChainId].outboundProofType);
}
return abi.encode(uaConfig.outboundProofType);
} else if (_configType == CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS) {
if (uaConfig.outboundBlockConfirmations == 0) {
return abi.encode(defaultAppConfig[_remoteChainId].outboundBlockConfirmations);
}
return abi.encode(uaConfig.outboundBlockConfirmations);
} else if (_configType == CONFIG_TYPE_ORACLE) {
if (uaConfig.oracle == address(0x0)) {
return abi.encode(defaultAppConfig[_remoteChainId].oracle);
}
return abi.encode(uaConfig.oracle);
} else {
revert("LayerZero: Invalid config type");
}
}
function estimateFees(
uint16 _dstChainId,
address _ua,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParams
) external view override returns (uint nativeFee, uint zroFee) {
ApplicationConfiguration memory uaConfig = _getAppConfig(_dstChainId, _ua);
bytes memory adapterParams;
if (_adapterParams.length > 0) {
adapterParams = _adapterParams;
} else {
adapterParams = defaultAdapterParams[_dstChainId][uaConfig.outboundProofType];
}
uint relayerFee = ILayerZeroRelayerV2(uaConfig.relayer).getFee(
_dstChainId,
uaConfig.outboundProofType,
_ua,
_payload.length,
adapterParams
);
address ua = _ua;
uint oracleFee = ILayerZeroOracleV2(uaConfig.oracle).getFee(
_dstChainId,
uaConfig.outboundProofType,
uaConfig.outboundBlockConfirmations,
ua
);
uint protocolFee = treasuryContract.getFees(_payInZRO, relayerFee, oracleFee);
_payInZRO ? zroFee = protocolFee : nativeFee = protocolFee;
nativeFee = nativeFee.add(relayerFee).add(oracleFee);
}
function withdrawZRO(address _to, uint _amount) external override nonReentrant {
require(msg.sender == address(treasuryContract), "LayerZero: only treasury");
treasuryZROFees = treasuryZROFees.sub(_amount);
layerZeroToken.safeTransfer(_to, _amount);
emit WithdrawZRO(msg.sender, _to, _amount);
}
function withdrawNative(address payable _to, uint _amount) external override nonReentrant {
require(_to != address(0x0), "LayerZero: _to cannot be zero address");
nativeFees[msg.sender] = nativeFees[msg.sender].sub(_amount);
(bool success, ) = _to.call{value: _amount}("");
require(success, "LayerZero: withdraw failed");
emit WithdrawNative(msg.sender, _to, _amount);
}
function setLayerZeroToken(address _layerZeroToken) external onlyOwner {
require(_layerZeroToken != address(0x0), "LayerZero: _layerZeroToken cannot be zero address");
layerZeroToken = IERC20(_layerZeroToken);
emit SetLayerZeroToken(_layerZeroToken);
}
function setTreasury(address _treasury) external onlyOwner {
require(_treasury != address(0x0), "LayerZero: treasury cannot be zero address");
treasuryContract = ILayerZeroTreasury(_treasury);
emit SetTreasury(_treasury);
}
function addInboundProofLibraryForChain(uint16 _chainId, address _library) external onlyOwner {
require(_library != address(0x0), "LayerZero: library cannot be zero address");
uint16 libId = maxInboundProofLibrary[_chainId];
require(libId < 65535, "LayerZero: can not add new library");
maxInboundProofLibrary[_chainId] = ++libId;
inboundProofLibrary[_chainId][libId] = _library;
emit AddInboundProofLibraryForChain(_chainId, _library);
}
function enableSupportedOutboundProof(uint16 _chainId, uint16 _proofType) external onlyOwner {
supportedOutboundProof[_chainId][_proofType] = true;
emit EnableSupportedOutboundProof(_chainId, _proofType);
}
function setDefaultConfigForChainId(
uint16 _chainId,
uint16 _inboundProofLibraryVersion,
uint64 _inboundBlockConfirmations,
address _relayer,
uint16 _outboundProofType,
uint64 _outboundBlockConfirmations,
address _oracle
) external onlyOwner {
require(
_inboundProofLibraryVersion <= maxInboundProofLibrary[_chainId] && _inboundProofLibraryVersion > 0,
"LayerZero: invalid inbound proof library version"
);
require(_inboundBlockConfirmations > 0, "LayerZero: invalid inbound block confirmation");
require(_relayer != address(0x0), "LayerZero: invalid relayer address");
require(supportedOutboundProof[_chainId][_outboundProofType], "LayerZero: invalid outbound proof type");
require(_outboundBlockConfirmations > 0, "LayerZero: invalid outbound block confirmation");
require(_oracle != address(0x0), "LayerZero: invalid oracle address");
defaultAppConfig[_chainId] = ApplicationConfiguration(
_inboundProofLibraryVersion,
_inboundBlockConfirmations,
_relayer,
_outboundProofType,
_outboundBlockConfirmations,
_oracle
);
emit SetDefaultConfigForChainId(
_chainId,
_inboundProofLibraryVersion,
_inboundBlockConfirmations,
_relayer,
_outboundProofType,
_outboundBlockConfirmations,
_oracle
);
}
function setDefaultAdapterParamsForChainId(
uint16 _chainId,
uint16 _proofType,
bytes calldata _adapterParams
) external onlyOwner {
defaultAdapterParams[_chainId][_proofType] = _adapterParams;
emit SetDefaultAdapterParamsForChainId(_chainId, _proofType, _adapterParams);
}
function setRemoteUln(uint16 _remoteChainId, bytes32 _remoteUln) external onlyOwner {
require(ulnLookup[_remoteChainId] == bytes32(0), "LayerZero: remote uln already set");
ulnLookup[_remoteChainId] = _remoteUln;
emit SetRemoteUln(_remoteChainId, _remoteUln);
}
function setChainAddressSize(uint16 _chainId, uint _size) external onlyOwner {
require(chainAddressSizeMap[_chainId] == 0, "LayerZero: remote chain address size already set");
chainAddressSizeMap[_chainId] = _size;
emit SetChainAddressSize(_chainId, _size);
}
function accruedNativeFee(address _address) external view override returns (uint) {
return nativeFees[_address];
}
function getOutboundNonce(uint16 _chainId, bytes calldata _path) external view override returns (uint64) {
return nonceContract.outboundNonce(_chainId, _path);
}
function _isContract(address addr) internal view returns (bool) {
uint size;
assembly {
size := extcodesize(addr)
}
return size != 0;
}
}
{
"compilationTarget": {
"contracts/UltraLightNodeV2.sol": "UltraLightNodeV2"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10000
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_endpoint","type":"address"},{"internalType":"address","name":"_nonceContract","type":"address"},{"internalType":"uint16","name":"_localChainId","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"address","name":"lib","type":"address"}],"name":"AddInboundProofLibraryForChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"userApplication","type":"address"},{"indexed":true,"internalType":"uint256","name":"configType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"newConfig","type":"bytes"}],"name":"AppConfigUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"proofType","type":"uint16"}],"name":"EnableSupportedOutboundProof","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":false,"internalType":"bytes32","name":"lookupHash","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"blockData","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"confirmations","type":"uint256"}],"name":"HashReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":true,"internalType":"address","name":"dstAddress","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"name":"InvalidDst","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":"bytes","name":"payload","type":"bytes"}],"name":"Packet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":true,"internalType":"address","name":"dstAddress","type":"address"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"name":"PacketReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"adapterParams","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"outboundProofType","type":"uint16"}],"name":"RelayerParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"}],"name":"SetChainAddressSize","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":true,"internalType":"uint16","name":"proofType","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"adapterParams","type":"bytes"}],"name":"SetDefaultAdapterParamsForChainId","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"inboundProofLib","type":"uint16"},{"indexed":false,"internalType":"uint64","name":"inboundBlockConfirm","type":"uint64"},{"indexed":false,"internalType":"address","name":"relayer","type":"address"},{"indexed":false,"internalType":"uint16","name":"outboundProofType","type":"uint16"},{"indexed":false,"internalType":"uint64","name":"outboundBlockConfirm","type":"uint64"},{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"SetDefaultConfigForChainId","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"SetLayerZeroToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"chainId","type":"uint16"},{"indexed":false,"internalType":"bytes32","name":"uln","type":"bytes32"}],"name":"SetRemoteUln","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"treasuryAddress","type":"address"}],"name":"SetTreasury","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"msgSender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawNative","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"msgSender","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawZRO","type":"event"},{"inputs":[],"name":"CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG_TYPE_ORACLE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG_TYPE_OUTBOUND_PROOF_TYPE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONFIG_TYPE_RELAYER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"accruedNativeFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"_library","type":"address"}],"name":"addInboundProofLibraryForChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"appConfig","outputs":[{"internalType":"uint16","name":"inboundProofLibraryVersion","type":"uint16"},{"internalType":"uint64","name":"inboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"relayer","type":"address"},{"internalType":"uint16","name":"outboundProofType","type":"uint16"},{"internalType":"uint64","name":"outboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"oracle","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"chainAddressSizeMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"defaultAdapterParams","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"defaultAppConfig","outputs":[{"internalType":"uint16","name":"inboundProofLibraryVersion","type":"uint16"},{"internalType":"uint64","name":"inboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"relayer","type":"address"},{"internalType":"uint16","name":"outboundProofType","type":"uint16"},{"internalType":"uint64","name":"outboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"oracle","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint16","name":"_proofType","type":"uint16"}],"name":"enableSupportedOutboundProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"address","name":"_ua","type":"address"},{"internalType":"bytes","name":"_payload","type":"bytes"},{"internalType":"bool","name":"_payInZRO","type":"bool"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateFees","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"address","name":"_ua","type":"address"}],"name":"getAppConfig","outputs":[{"components":[{"internalType":"uint16","name":"inboundProofLibraryVersion","type":"uint16"},{"internalType":"uint64","name":"inboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"relayer","type":"address"},{"internalType":"uint16","name":"outboundProofType","type":"uint16"},{"internalType":"uint64","name":"outboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"oracle","type":"address"}],"internalType":"struct ILayerZeroUltraLightNodeV2.ApplicationConfiguration","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"address","name":"_ua","type":"address"},{"internalType":"uint256","name":"_configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"getOutboundNonce","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"hashLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"inboundProofLibrary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"layerZeroToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"localChainId","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"maxInboundProofLibrary","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nativeFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonceContract","outputs":[{"internalType":"contract NonceContract","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ua","type":"address"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes","name":"_path","type":"bytes"},{"internalType":"bytes","name":"_payload","type":"bytes"},{"internalType":"address payable","name":"_refundAddress","type":"address"},{"internalType":"address","name":"_zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"send","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"setChainAddressSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"address","name":"_ua","type":"address"},{"internalType":"uint256","name":"_configType","type":"uint256"},{"internalType":"bytes","name":"_config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint16","name":"_proofType","type":"uint16"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"setDefaultAdapterParamsForChainId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint16","name":"_inboundProofLibraryVersion","type":"uint16"},{"internalType":"uint64","name":"_inboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"_relayer","type":"address"},{"internalType":"uint16","name":"_outboundProofType","type":"uint16"},{"internalType":"uint64","name":"_outboundBlockConfirmations","type":"uint64"},{"internalType":"address","name":"_oracle","type":"address"}],"name":"setDefaultConfigForChainId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_layerZeroToken","type":"address"}],"name":"setLayerZeroToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"bytes32","name":"_remoteUln","type":"bytes32"}],"name":"setRemoteUln","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"supportedOutboundProof","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryContract","outputs":[{"internalType":"contract ILayerZeroTreasury","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasuryZROFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"ulnLookup","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes32","name":"_lookupHash","type":"bytes32"},{"internalType":"uint256","name":"_confirmations","type":"uint256"},{"internalType":"bytes32","name":"_blockData","type":"bytes32"}],"name":"updateHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"address","name":"_dstAddress","type":"address"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"},{"internalType":"bytes32","name":"_lookupHash","type":"bytes32"},{"internalType":"bytes32","name":"_blockData","type":"bytes32"},{"internalType":"bytes","name":"_transactionProof","type":"bytes"}],"name":"validateTransactionProof","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawZRO","outputs":[],"stateMutability":"nonpayable","type":"function"}]