Source Code
More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 373 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Approve | 130413762 | 380 days ago | IN | 0 ETH | 0.000000322191 | ||||
| Approve | 129501356 | 401 days ago | IN | 0 ETH | 0.000000132474 | ||||
| Approve | 124466827 | 517 days ago | IN | 0 ETH | 0.000000037604 | ||||
| Approve | 120356139 | 612 days ago | IN | 0 ETH | 0.000001977504 | ||||
| Approve | 119760017 | 626 days ago | IN | 0 ETH | 0.000002978655 | ||||
| Approve | 117891491 | 670 days ago | IN | 0 ETH | 0.000000947212 | ||||
| Approve | 117565501 | 677 days ago | IN | 0 ETH | 0.000000234564 | ||||
| Send | 116499155 | 702 days ago | IN | 0.01 ETH | 0.000136398365 | ||||
| Send | 116499149 | 702 days ago | IN | 0.01 ETH | 0.00013823031 | ||||
| Send | 116499145 | 702 days ago | IN | 0.01 ETH | 0.000132638646 | ||||
| Send | 116498790 | 702 days ago | IN | 0.01 ETH | 0.000121789878 | ||||
| Send | 116498781 | 702 days ago | IN | 0.000283418158694 ETH | 0.000140328964 | ||||
| Send | 116498780 | 702 days ago | IN | 0.000675744489684 ETH | 0.000142454605 | ||||
| Send | 116498579 | 702 days ago | IN | 0.000283418158694 ETH | 0.000134479192 | ||||
| Send | 116498578 | 702 days ago | IN | 0.000165201341334 ETH | 0.000133780383 | ||||
| Send | 116498516 | 702 days ago | IN | 0.002 ETH | 0.000109422672 | ||||
| Approve | 116403208 | 704 days ago | IN | 0 ETH | 0.00004141627 | ||||
| Send | 116390784 | 704 days ago | IN | 0.000732171829684 ETH | 0.000163508037 | ||||
| Transfer | 116390721 | 704 days ago | IN | 0 ETH | 0.000082965982 | ||||
| Send | 116307290 | 706 days ago | IN | 0.000175895266382 ETH | 0.000075854475 | ||||
| Send | 116245036 | 708 days ago | IN | 0.000551204453998 ETH | 0.000116122086 | ||||
| Approve | 116235940 | 708 days ago | IN | 0 ETH | 0.000043555174 | ||||
| Send | 116235439 | 708 days ago | IN | 0.000521337273998 ETH | 0.000078417018 | ||||
| Approve | 116195336 | 709 days ago | IN | 0 ETH | 0.000035143304 | ||||
| Send | 116186198 | 709 days ago | IN | 0.000175863077768 ETH | 0.00006877255 |
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 116499155 | 702 days ago | 0.01 ETH | ||||
| 116499149 | 702 days ago | 0.01 ETH | ||||
| 116499145 | 702 days ago | 0.01 ETH | ||||
| 116498790 | 702 days ago | 0.01 ETH | ||||
| 116498781 | 702 days ago | 0.000283418158694 ETH | ||||
| 116498780 | 702 days ago | 0.000675744489684 ETH | ||||
| 116498579 | 702 days ago | 0.000283418158694 ETH | ||||
| 116498578 | 702 days ago | 0.000165201341334 ETH | ||||
| 116498516 | 702 days ago | 0.002 ETH | ||||
| 116390784 | 704 days ago | 0.000732171829684 ETH | ||||
| 116307290 | 706 days ago | 0.000175895266382 ETH | ||||
| 116245036 | 708 days ago | 0.000551204453998 ETH | ||||
| 116235439 | 708 days ago | 0.000521337273998 ETH | ||||
| 116186198 | 709 days ago | 0.000175863077768 ETH | ||||
| 116186197 | 709 days ago | 0.00032359377119 ETH | ||||
| 116186195 | 709 days ago | 0.000423232873998 ETH | ||||
| 116186151 | 709 days ago | 0.000175863077768 ETH | ||||
| 116186150 | 709 days ago | 0.00032359377119 ETH | ||||
| 116186149 | 709 days ago | 0.000423232873998 ETH | ||||
| 116183966 | 709 days ago | 0.00032359377119 ETH | ||||
| 116172600 | 709 days ago | 0.000305131785324 ETH | ||||
| 116171837 | 709 days ago | 0.000305131785324 ETH | ||||
| 116171836 | 709 days ago | 0.000445027528132 ETH | ||||
| 116167884 | 709 days ago | 0.000157401091902 ETH | ||||
| 116162323 | 710 days ago | 0.000828154228132 ETH |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
OMNI404
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import {O404} from "./O404.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
// ...........................................................................
// ,xKXK0KXKd, .oXNNK: ,ONXXx..kNNXd. .kNk' .xNK: .oKNNd. ;kKK00X0d. ;OXNK;
// ;0NKl...lKN0,.dNNXNk..oXXNNx..kNNNXd..kNO' .kNK: ;k0OKNx. ,0N0:..oXNd. .oK00NK:
// .oNNx. .xNNo.oNKkKKc:0XO0Nx..kN0x0Xd:kNO' .kNK: .lKO::0Nx. cXNx. ,0N0' ,kKd,dNK:
// lXNk. .kNXl.dN0ldN0OXklONx..kNO;:0XOKNO' .kNK:.dXKd:oKNOc.cXNk. ;KNO,:0NOcckNXd,
// .xNXxc;ckXXx..dN0;;0NNXc,ONx..kNO' :0NNNO' .kNX:'okxxk0NNKk;'xNXd;ckNKl.;xkxxkKNN0o.
// .:dO000Od:. cOd'.lOOo..oOl..oOd. ;xOOo. .oOx, ;xOl. .cxO00Od; .oOx;
// ...........................................................................
contract OMNI404 is O404 {
string public baseURI;
constructor(uint256 _initialSupplyERC20, address _lzEndpoint, address _delegate)
O404("OMNI404", "O404", 50, _lzEndpoint, _delegate)
{
// Do not mint the ERC721s to the initial owner, as it's a waste of gas.
_setWhitelist(_delegate, true);
_mintERC20(_delegate, _initialSupplyERC20);
}
function tokenURI(uint256 id) public view override returns (string memory) {
string memory image = string.concat(Strings.toString(id), ".JPG");
string memory jsonPreImage = string.concat(
string.concat(
string.concat('{"name": "OMNI404 #', Strings.toString(id)),
'","description":"The frontier of permissionless assets.","external_url":"https://twitter.com/omnichain404","image":"'
),
string.concat(baseURI, image)
);
string memory jsonPostImage = string.concat('"}');
return string.concat("data:application/json;utf8,", string.concat(jsonPreImage, jsonPostImage));
}
function setBaseURI(string memory _baseURI) public onlyOwner {
baseURI = _baseURI;
}
function setWhitelist(address account_, bool value_) external onlyOwner {
_setWhitelist(account_, value_);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DoubleEndedQueue} from "./utils/DoubleEndedQueue.sol";
import {IERC404} from "./interfaces/IERC404.sol";
import {IOFT, OFTCore} from "LayerZero-v2/oapp/contracts/oft/OFTCore.sol";
abstract contract ERC721Receiver {
function onERC721Received(address, address, uint256, bytes calldata) external virtual returns (bytes4) {
return ERC721Receiver.onERC721Received.selector;
}
}
/**
* @title O404 Contract
* @dev O404 is an ERC-404 token that extends the functionality of the OFTCore contract.
*/
abstract contract O404 is OFTCore, IERC404 {
using DoubleEndedQueue for DoubleEndedQueue.Bytes32Deque;
/// @dev The queue of ERC-721 tokens stored in the contract.
DoubleEndedQueue.Bytes32Deque private _storedERC721Ids;
// //////// Events ////////
// event ERC20Transfer(address indexed from, address indexed to, uint256 amount);
// event Approval(address indexed owner, address indexed spender, uint256 amount);
// event Transfer(address indexed from, address indexed to, uint256 indexed id);
// event ERC721Approval(address indexed owner, address indexed spender, uint256 indexed id);
// event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
// //////// Errors ////////
// error NotFound();
// error AlreadyExists();
// error InvalidRecipient();
// error InvalidSender();
// error UnsafeRecipient();
//////// Metadata ////////
/// @dev Token name
string public name;
/// @dev Token symbol
string public symbol;
/// @dev Decimals for ERC-20 representation: fixed at 18
uint8 public immutable decimals = 18;
/// @dev Units for ERC-20 representation: fixed at 10^18
uint256 public immutable units = 10 ** decimals;
/// @dev Max supply for ERC-20 representation
uint256 public immutable maxTotalSupplyERC20;
/// @dev Max supply for ERC-721 representation
uint256 public immutable maxTotalSupplyERC721;
/// @dev Total supply in ERC-20 representation
uint256 public totalSupply;
/// @dev Current mint counter which also represents the highest minted id, monotonically increasing to ensure accurate ownership
uint256 public minted;
//////// Mappings ////////
/// @dev Balance of user in ERC-20 representation
mapping(address => uint256) public balanceOf;
/// @dev Allowance of user in ERC-20 representation
mapping(address => mapping(address => uint256)) public allowance;
/// @dev Approval in ERC-721 representaion
mapping(uint256 => address) public getApproved;
/// @dev Approval for all in ERC-721 representation
mapping(address => mapping(address => bool)) public isApprovedForAll;
/// @dev Owner of id in ERC-721 representation
mapping(uint256 => address) internal _ownerOf; // TODO: check
/// @dev Array of owned ids in ERC-721 representation
mapping(address => uint256[]) internal _owned; // TODO: check
/// @dev Tracks indices for the _owned mapping
mapping(uint256 => uint256) internal _ownedIndex; // TODO: check
/// @dev Addresses whitelisted from minting / burning for gas savings (pairs, routers, etc)
mapping(address => bool) public whitelist;
/**
* @dev Constructor for the OFT contract.
* @param _name The name of the OFT.
* @param _symbol The symbol of the OFT.
* @param _maxTotalSupplyERC721 Max supply for ERC-721 representation
* @param _lzEndpoint The LayerZero endpoint address.
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
*/
constructor(
string memory _name,
string memory _symbol,
uint256 _maxTotalSupplyERC721,
address _lzEndpoint,
address _delegate
) OFTCore(decimals, _lzEndpoint, _delegate) {
name = _name;
symbol = _symbol;
maxTotalSupplyERC721 = _maxTotalSupplyERC721;
maxTotalSupplyERC20 = maxTotalSupplyERC721 * units;
}
//////////////////////////////////////////////////////////////////////////////////////
// OFT FUNCTIONS
/**
* @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 Retrieves the address of the underlying ERC20 implementation.
* @return The address of the OFT token.
*
* @dev In the case of OFT, address(this) and erc20 are the same contract.
*/
function token() external view returns (address) {
return address(this);
}
/**
* @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 OFT where the contract IS the token, approval is NOT required.
*/
function approvalRequired() external pure virtual returns (bool) {
return false;
}
/**
* @dev Burns tokens from the sender's specified balance.
* @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.
*/
function _debit(uint256 _amountLD, uint256 _minAmountLD, uint32 _dstEid)
internal
virtual
override
returns (uint256 amountSentLD, uint256 amountReceivedLD)
{
(amountSentLD, amountReceivedLD) = _debitView(_amountLD, _minAmountLD, _dstEid);
// @dev In NON-default OFT, amountSentLD could be 100, with a 10% fee, the amountReceivedLD amount is 90,
// therefore amountSentLD CAN differ from amountReceivedLD.
// @dev Default OFT burns on src.
_burnERC20(msg.sender, 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.
*/
function _credit(address _to, uint256 _amountLD, uint32 /*_srcEid*/ )
internal
virtual
override
returns (uint256 amountReceivedLD)
{
// @dev Default OFT mints on dst.
_mintERC20(_to, _amountLD);
// @dev In the case of NON-default OFT, the _amountLD MIGHT not be == amountReceivedLD.
return _amountLD;
}
//////////////////////////////////////////////////////////////////////////////////////
// ERC404 FUNCTIONS
/// @notice Function to find owner of a given ERC-721 token
function ownerOf(uint256 id_) public view virtual returns (address nftOwner) {
nftOwner = _ownerOf[id_];
// If the id_ is beyond the range of ERC-721 supply, is 0, or the token is not owned by anyone, revert.
if (id_ > maxTotalSupplyERC721 || id_ == 0 || nftOwner == address(0)) {
revert NotFound();
}
}
function erc721BalanceOf(address owner_) public view virtual returns (uint256) {
return _owned[owner_].length;
}
function erc20BalanceOf(address owner_) public view virtual returns (uint256) {
return balanceOf[owner_];
}
/// @notice Function for token approvals
/// @dev This function assumes the operator is attempting to approve an ERC-721 if valueOrId is less than the minted count. Note: Unlike setApprovalForAll, spender_ must be allowed to be 0x0 so that approval can be revoked.
function approve(address spender_, uint256 valueOrId_) public virtual returns (bool) {
// The ERC-721 tokens are 1-indexed, so 0 is not a valid id and indicates that operator is attempting to set the ERC-20 allowance to 0.
if (valueOrId_ <= maxTotalSupplyERC721 && valueOrId_ > 0) {
// Intention is to approve as ERC-721 token (id).
uint256 id = valueOrId_;
address nftOwner = _ownerOf[id];
if (msg.sender != nftOwner && !isApprovedForAll[nftOwner][msg.sender]) {
revert Unauthorized();
}
getApproved[id] = spender_;
emit Approval(nftOwner, spender_, id);
emit ERC721Approval(nftOwner, spender_, id);
} else {
// Intention is to approve as ERC-20 token (value).
uint256 value = valueOrId_;
allowance[msg.sender][spender_] = value;
emit Approval(msg.sender, spender_, value);
emit ERC20Approval(msg.sender, spender_, value);
}
return true;
}
/// @notice Function for ERC-721 approvals
function setApprovalForAll(address operator_, bool approved_) public virtual {
// Prevent approvals to 0x0.
if (operator_ == address(0)) {
revert InvalidOperator();
}
isApprovedForAll[msg.sender][operator_] = approved_;
emit ApprovalForAll(msg.sender, operator_, approved_);
}
/// @notice Function for mixed transfers from an operator that may be different than 'from'.
/// @dev This function assumes the operator is attempting to transfer an ERC-721 if valueOrId is less than or equal to current max id.
function transferFrom(address from_, address to_, uint256 valueOrId_) public virtual returns (bool) {
// Prevent burning tokens to the 0 address.
// TODO: remove
if (to_ == address(0)) {
revert InvalidRecipient();
}
if (valueOrId_ <= maxTotalSupplyERC721) {
// Intention is to transfer as ERC-721 token (id).
uint256 id = valueOrId_;
if (from_ != _ownerOf[id]) {
revert InvalidSender();
}
// Check that the operator is approved for the transfer.
if (msg.sender != from_ && !isApprovedForAll[from_][msg.sender] && msg.sender != getApproved[id]) {
revert Unauthorized();
}
// Transfer 1 * units ERC-20 and 1 ERC-721 token.
_transferERC20(from_, to_, units);
_transferERC721(from_, to_, id);
} else {
// Intention is to transfer as ERC-20 token (value).
uint256 value = valueOrId_;
uint256 allowed = allowance[from_][msg.sender];
// Check that the operator has sufficient allowance.
if (allowed != type(uint256).max) {
if (allowed < value) {
revert InsufficientAllowance();
}
allowance[from_][msg.sender] = allowed - value;
}
// Transferring ERC-20s directly requires the _transfer function.
_transfer(from_, to_, value);
}
return true;
}
/// @notice Function for mixed transfers.
/// @dev This function assumes the operator is attempting to transfer an ERC-721 if valueOrId is lte the highest minted ERC-721 id.
function transfer(address to_, uint256 valueOrId_) public virtual returns (bool) {
// Prevent burning tokens to the 0 address.
if (to_ == address(0)) {
revert InvalidRecipient();
}
if (valueOrId_ <= maxTotalSupplyERC721) {
// Intention is to transfer as ERC-721 token (id).
uint256 id = valueOrId_;
if (msg.sender != _ownerOf[id]) {
revert Unauthorized();
}
// Transfer 1 * units ERC-20 and 1 ERC-721 token.
// This this path is used to ensure the exact ERC-721 specified is transferred.
_transferERC20(msg.sender, to_, units);
_transferERC721(msg.sender, to_, id);
} else {
// Intention is to transfer as ERC-20 token (value).
uint256 value = valueOrId_;
// Transferring ERC-20s directly requires the _transfer function.
_transfer(msg.sender, to_, value);
}
return true;
}
/// @notice Function for ERC-721 transfers with contract support.
function safeTransferFrom(address from_, address to_, uint256 id_) public virtual {
transferFrom(from_, to_, id_);
if (
to_.code.length != 0
&& ERC721Receiver(to_).onERC721Received(msg.sender, from_, id_, "")
!= ERC721Receiver.onERC721Received.selector
) {
revert UnsafeRecipient();
}
}
/// @notice Function for ERC-721 transfers with contract support and callback data.
function safeTransferFrom(address from_, address to_, uint256 id_, bytes calldata data_) public virtual {
transferFrom(from_, to_, id_);
if (
to_.code.length != 0
&& ERC721Receiver(to_).onERC721Received(msg.sender, from_, id_, data_)
!= ERC721Receiver.onERC721Received.selector
) {
revert UnsafeRecipient();
}
}
/// @notice This is the lowest level ERC-20 transfer function, which should be used for both normal ERC-20 transfers as well as minting.
/// Note that this function allows transfers to and from 0x0.
function _transferERC20(address from_, address to_, uint256 value_) internal virtual {
// Minting is a special case for which we should not check the balance of the sender, and we should increase the total supply.
if (from_ == address(0)) {
if (totalSupply + value_ > maxTotalSupplyERC20) {
revert MaxERC20SupplyReached();
}
unchecked {
totalSupply += value_;
}
} else {
// For transfers not from the 0x0 address, check for insufficient balance.
if (balanceOf[from_] < value_) {
revert InsufficientBalance();
}
// Deduct value from sender's balance.
balanceOf[from_] -= value_;
// If the recipient is the 0x0 address, burn the tokens.
if (to_ == address(0)) {
// Burning is a special case for which we should decrease the total supply.
unchecked {
totalSupply -= value_;
}
}
}
// If this is not a burn
if (to_ != address(0)) {
// Update the recipient's balance.
unchecked {
balanceOf[to_] += value_;
}
}
emit Transfer(from_, to_, value_);
emit ERC20Transfer(from_, to_, value_);
}
/// @notice Consolidated record keeping function for transferring ERC-721s.
/// @dev Assign the token to the new owner, and remove from the old owner.
/// Note that this function allows transfers to and from 0x0.
function _transferERC721(address from_, address to_, uint256 id_) internal virtual {
// If this is not a mint, handle record keeping for transfer from previous owner.
if (from_ != address(0)) {
// On transfer of an NFT, any previous approval is reset.
delete getApproved[id_];
// update _owned for sender
uint256 updatedId = _owned[from_][_owned[from_].length - 1];
_owned[from_][_ownedIndex[id_]] = updatedId;
// pop
_owned[from_].pop();
// update index for the moved id
_ownedIndex[updatedId] = _ownedIndex[id_];
}
// Update owner of the token to the new owner.
_ownerOf[id_] = to_;
// Push token onto the new owner's stack.
_owned[to_].push(id_);
// Update index for new owner's stack.
_ownedIndex[id_] = _owned[to_].length - 1;
emit Transfer(from_, to_, id_);
emit ERC721Transfer(from_, to_, id_);
}
/// @notice Internal function for ERC-20 transfers.
/// Also handles any ERC-721 transfers that may be required.
function _transfer(address from, address to, uint256 amount) internal returns (bool) {
uint256 erc20BalanceOfSenderBefore = erc20BalanceOf(from);
uint256 erc20BalanceOfReceiverBefore = erc20BalanceOf(to);
_transferERC20(from, to, amount);
// Skip burn for certain addresses to save gas
if (!whitelist[from]) {
uint256 num721ToBurn = (erc20BalanceOfSenderBefore / units) - (balanceOf[from] / units);
for (uint256 i = 0; i < num721ToBurn; i++) {
_burnERC721(from);
}
}
// Skip minting for certain addresses to save gas
if (!whitelist[to]) {
uint256 num721ToMint = (balanceOf[to] / units) - (erc20BalanceOfReceiverBefore / units);
for (uint256 i = 0; i < num721ToMint; i++) {
_mintERC721(to);
}
}
return true;
}
/// @notice Internal function for ERC20 minting
/// @dev This function will allow minting of new ERC20s up to the maxTotalSupplyERC20.
function _mintERC20(address to_, uint256 value_) internal virtual {
/// You cannot mint to the zero address (you can't mint and immediately burn in the same transfer).
if (to_ == address(0)) {
revert InvalidRecipient();
}
uint256 erc20BalanceOfReceiverBefore = erc20BalanceOf(to_);
_transferERC20(address(0), to_, value_);
if (!whitelist[to_]) {
uint256 num721ToMint = (balanceOf[to_] / units) - (erc20BalanceOfReceiverBefore / units);
for (uint256 i = 0; i < num721ToMint; i++) {
_mintERC721(to_);
}
}
}
function _burnERC20(address from_, uint256 value_) internal virtual {
/// You cannot mint to the zero address (you can't mint and immediately burn in the same transfer).
if (from_ == address(0)) {
revert InvalidSender();
}
uint256 erc20BalanceOfSenderBefore = erc20BalanceOf(from_);
_transferERC20(from_, address(0), value_);
// Skip burn for certain addresses to save gas
if (!whitelist[from_]) {
uint256 num721ToBurn = (erc20BalanceOfSenderBefore / units) - (balanceOf[from_] / units);
for (uint256 i = 0; i < num721ToBurn; i++) {
_burnERC721(from_);
}
}
}
/// @notice Internal function for ERC-721 minting and retrieval from the bank.
/// @dev This function will allow minting of new ERC-721s up to the maxTotalSupplyERC20. It will first try to pull from the bank, and if the bank is empty, it will mint a new token.
function _mintERC721(address to_) internal virtual {
if (to_ == address(0) || to_ == address(this)) {
revert InvalidRecipient();
}
uint256 id;
if (!DoubleEndedQueue.empty(_storedERC721Ids)) {
// If there are any tokens in the bank, use those.
id = uint256(_storedERC721Ids.popBack());
} else {
// Otherwise, mint a new token.
minted++;
id = minted;
if (minted > maxTotalSupplyERC721) {
revert MaxERC721SupplyReached();
}
}
address nftOwner = _ownerOf[id];
// The token should not already belong to anyone besides 0x0 or this contract. If it does, something is wrong, as this should never happen.
if (nftOwner != address(0) && nftOwner != address(this)) {
revert AlreadyExists();
}
// Transfer the token to the recipient, either transferring from the contract's bank or minting.
_transferERC721(nftOwner, to_, id);
}
/// @notice Internal function for ERC-721 deposits to bank (this contract).
/// @dev This function will allow depositing of ERC-721s to the bank, which can be retrieved by future minters.
function _burnERC721(address from_) internal virtual {
if (from_ == address(0) || from_ == address(this)) {
revert InvalidSender();
}
// Retrieve the latest token added to the owner's stack (LIFO).
uint256 id = _owned[from_][_owned[from_].length - 1];
// Transfer the token to the contract.
_transferERC721(from_, address(this), id); // TODO: should this be set to address(0) ?
// Record the token in the contract's bank queue.
_storedERC721Ids.pushFront(bytes32(id));
}
/// @notice Initialization function to set pairs / etc, saving gas by avoiding mint / burn on unnecessary targets
function _setWhitelist(address target_, bool state_) internal virtual {
// If the target has at least 1 full ERC-20 token, they should not be removed from the whitelist because if they were and then they attempted to transfer, it would revert as they would not necessarily have ehough ERC-721s to bank.
if (erc20BalanceOf(target_) >= units && !state_) {
revert CannotRemoveFromWhitelist();
}
whitelist[target_] = state_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
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].
*/
// 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 {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, code)
revert(0x00, 0x24)
}
}
}
/**
* @dev A sequence of items with the ability to efficiently push and pop items (i.e. insert and remove) on both ends of
* the sequence (called front and back). Among other access patterns, it can be used to implement efficient LIFO and
* FIFO queues. Storage use is optimized, and all operations are O(1) constant time. This includes {clear}, given that
* the existing queue contents are left in storage.
*
* The struct is called `Bytes32Deque`. Other types can be cast to and from `bytes32`. This data structure can only be
* used in storage, and not in memory.
* ```solidity
* DoubleEndedQueue.Bytes32Deque queue;
* ```
*/
library DoubleEndedQueue {
/**
* @dev Indices are 128 bits so begin and end are packed in a single storage slot for efficient access.
*
* Struct members have an underscore prefix indicating that they are "private" and should not be read or written to
* directly. Use the functions provided below instead. Modifying the struct manually may violate assumptions and
* lead to unexpected behavior.
*
* The first item is at data[begin] and the last item is at data[end - 1]. This range can wrap around.
*/
struct Bytes32Deque {
uint128 _begin;
uint128 _end;
mapping(uint128 index => bytes32) _data;
}
/**
* @dev Inserts an item at the end of the queue.
*
* Reverts with {Panic-RESOURCE_ERROR} if the queue is full.
*/
function pushBack(Bytes32Deque storage deque, bytes32 value) internal {
unchecked {
uint128 backIndex = deque._end;
if (backIndex + 1 == deque._begin) Panic.panic(Panic.RESOURCE_ERROR);
deque._data[backIndex] = value;
deque._end = backIndex + 1;
}
}
/**
* @dev Removes the item at the end of the queue and returns it.
*
* Reverts with {Panic-EMPTY_ARRAY_POP} if the queue is empty.
*/
function popBack(Bytes32Deque storage deque) internal returns (bytes32 value) {
unchecked {
uint128 backIndex = deque._end;
if (backIndex == deque._begin) Panic.panic(Panic.EMPTY_ARRAY_POP);
--backIndex;
value = deque._data[backIndex];
delete deque._data[backIndex];
deque._end = backIndex;
}
}
/**
* @dev Inserts an item at the beginning of the queue.
*
* Reverts with {Panic-RESOURCE_ERROR} if the queue is full.
*/
function pushFront(Bytes32Deque storage deque, bytes32 value) internal {
unchecked {
uint128 frontIndex = deque._begin - 1;
if (frontIndex == deque._end) Panic.panic(Panic.RESOURCE_ERROR);
deque._data[frontIndex] = value;
deque._begin = frontIndex;
}
}
/**
* @dev Removes the item at the beginning of the queue and returns it.
*
* Reverts with {Panic-EMPTY_ARRAY_POP} if the queue is empty.
*/
function popFront(Bytes32Deque storage deque) internal returns (bytes32 value) {
unchecked {
uint128 frontIndex = deque._begin;
if (frontIndex == deque._end) Panic.panic(Panic.EMPTY_ARRAY_POP);
value = deque._data[frontIndex];
delete deque._data[frontIndex];
deque._begin = frontIndex + 1;
}
}
/**
* @dev Returns the item at the beginning of the queue.
*
* Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the queue is empty.
*/
function front(Bytes32Deque storage deque) internal view returns (bytes32 value) {
if (empty(deque)) Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS);
return deque._data[deque._begin];
}
/**
* @dev Returns the item at the end of the queue.
*
* Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the queue is empty.
*/
function back(Bytes32Deque storage deque) internal view returns (bytes32 value) {
if (empty(deque)) Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS);
unchecked {
return deque._data[deque._end - 1];
}
}
/**
* @dev Return the item at a position in the queue given by `index`, with the first item at 0 and last item at
* `length(deque) - 1`.
*
* Reverts with {Panic-ARRAY_OUT_OF_BOUNDS} if the index is out of bounds.
*/
function at(Bytes32Deque storage deque, uint256 index) internal view returns (bytes32 value) {
if (index >= length(deque)) Panic.panic(Panic.ARRAY_OUT_OF_BOUNDS);
// By construction, length is a uint128, so the check above ensures that index can be safely downcast to uint128
unchecked {
return deque._data[deque._begin + uint128(index)];
}
}
/**
* @dev Resets the queue back to being empty.
*
* NOTE: The current items are left behind in storage. This does not affect the functioning of the queue, but misses
* out on potential gas refunds.
*/
function clear(Bytes32Deque storage deque) internal {
deque._begin = 0;
deque._end = 0;
}
/**
* @dev Returns the number of items in the queue.
*/
function length(Bytes32Deque storage deque) internal view returns (uint256) {
unchecked {
return uint256(deque._end - deque._begin);
}
}
/**
* @dev Returns true if the queue is empty.
*/
function empty(Bytes32Deque storage deque) internal view returns (bool) {
return deque._end == deque._begin;
}
}//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.20;
interface IERC404 {
event Approval(address indexed owner, address indexed spender, uint256 valueOrId);
event ERC20Approval(address owner, address spender, uint256 value);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
event ERC721Approval(address indexed owner, address indexed spender, uint256 indexed id);
event Transfer(address indexed from, address indexed to, uint256 indexed valueOrId);
event ERC20Transfer(address indexed from, address indexed to, uint256 amount);
event ERC721Transfer(address indexed from, address indexed to, uint256 indexed id);
error NotFound();
error InvalidId();
error AlreadyExists();
error InvalidRecipient();
error InvalidSender();
error InvalidSpender();
error InvalidOperator();
error UnsafeRecipient();
error NotWhitelisted();
error Unauthorized();
error InsufficientAllowance();
error InsufficientBalance();
error MaxERC20SupplyReached();
error MaxERC721SupplyReached();
error DecimalsTooLow();
error CannotRemoveFromWhitelist();
function ownerOf(uint256 id_) external view returns (address nftOwner);
function tokenURI(uint256 id_) external view returns (string memory);
function approve(address spender_, uint256 valueOrId) external returns (bool);
function setApprovalForAll(address operator_, bool approved_) external;
function transferFrom(address from_, address to, uint256 valueOrId_) external returns (bool);
function transfer(address to_, uint256 amount_) external returns (bool);
function safeTransferFrom(address from_, address to_, uint256 id_) external;
function safeTransferFrom(address from, address to, uint256 id, bytes calldata data) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OApp, Origin } from "../oapp/OApp.sol";
import { OAppOptionsType3 } from "../oapp/libs/OAppOptionsType3.sol";
import { IOAppMsgInspector } from "../oapp/interfaces/IOAppMsgInspector.sol";
import { OAppPreCrimeSimulator } from "../precrime/OAppPreCrimeSimulator.sol";
import { IOFT, SendParam, OFTLimit, OFTReceipt, OFTFeeDetail, MessagingReceipt, MessagingFee } from "./interfaces/IOFT.sol";
import { OFTMsgCodec } from "./libs/OFTMsgCodec.sol";
import { OFTComposeMsgCodec } from "./libs/OFTComposeMsgCodec.sol";
/**
* @title OFTCore
* @dev Abstract contract for the OftChain (OFT) token.
*/
abstract contract OFTCore is IOFT, OApp, OAppPreCrimeSimulator, OAppOptionsType3 {
using OFTMsgCodec for bytes;
using OFTMsgCodec for bytes32;
// @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;
// Address of an optional contract to inspect both 'message' and 'options'
address public msgInspector;
event MsgInspectorSet(address inspector);
/**
* @dev Constructor.
* @param _localDecimals The decimals of the token on the local chain (this chain).
* @param _endpoint The address of the LayerZero endpoint.
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
*/
constructor(uint8 _localDecimals, address _endpoint, address _delegate) OApp(_endpoint, _delegate) {
if (_localDecimals < sharedDecimals()) revert InvalidLocalDecimals();
decimalConversionRate = 10 ** (_localDecimals - sharedDecimals());
}
/**
* @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 {
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(
_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);
// @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
if (msgInspector != address(0)) IOAppMsgInspector(msgInspector).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 _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(
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: MIT
pragma solidity ^0.8.20;
// @dev Import the 'MessagingFee' and 'MessagingReceipt' so it's exposed to OApp implementers
// solhint-disable-next-line no-unused-import
import { OAppSender, MessagingFee, MessagingReceipt } from "./OAppSender.sol";
// @dev Import the 'Origin' so it's exposed to OApp implementers
// solhint-disable-next-line no-unused-import
import { OAppReceiver, Origin } from "./OAppReceiver.sol";
import { OAppCore } from "./OAppCore.sol";
/**
* @title OApp
* @dev Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.
*/
abstract contract OApp is OAppSender, OAppReceiver {
/**
* @dev Constructor to initialize the OApp with the provided endpoint and owner.
* @param _endpoint The address of the LOCAL LayerZero endpoint.
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
*/
constructor(address _endpoint, address _delegate) OAppCore(_endpoint, _delegate) {}
/**
* @notice Retrieves the OApp version information.
* @return senderVersion The version of the OAppSender.sol implementation.
* @return receiverVersion The version of the OAppReceiver.sol implementation.
*/
function oAppVersion()
public
pure
virtual
override(OAppSender, OAppReceiver)
returns (uint64 senderVersion, uint64 receiverVersion)
{
return (SENDER_VERSION, RECEIVER_VERSION);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IOAppOptionsType3, EnforcedOptionParam } from "../interfaces/IOAppOptionsType3.sol";
/**
* @title OAppOptionsType3
* @dev Abstract contract implementing the IOAppOptionsType3 interface with type 3 options.
*/
abstract contract OAppOptionsType3 is IOAppOptionsType3, Ownable {
uint16 internal constant OPTION_TYPE_3 = 3;
// @dev The "msgType" should be defined in the child contract.
mapping(uint32 eid => mapping(uint16 msgType => bytes enforcedOption)) public enforcedOptions;
/**
* @dev Sets the enforced options for specific endpoint and message type combinations.
* @param _enforcedOptions An array of EnforcedOptionParam structures specifying enforced options.
*
* @dev Only the owner/admin of the OApp can call this function.
* @dev Provides a way for the OApp to enforce things like paying for PreCrime, AND/OR minimum dst lzReceive gas amounts etc.
* @dev These enforced options can vary as the potential options/execution on the remote may differ as per the msgType.
* eg. Amount of lzReceive() gas necessary to deliver a lzCompose() message adds overhead you dont want to pay
* if you are only making a standard LayerZero message ie. lzReceive() WITHOUT sendCompose().
*/
function setEnforcedOptions(EnforcedOptionParam[] calldata _enforcedOptions) public virtual onlyOwner {
for (uint256 i = 0; i < _enforcedOptions.length; i++) {
// @dev Enforced options are only available for optionType 3, as type 1 and 2 dont support combining.
_assertOptionsType3(_enforcedOptions[i].options);
enforcedOptions[_enforcedOptions[i].eid][_enforcedOptions[i].msgType] = _enforcedOptions[i].options;
}
emit EnforcedOptionSet(_enforcedOptions);
}
/**
* @notice Combines options for a given endpoint and message type.
* @param _eid The endpoint ID.
* @param _msgType The OAPP message type.
* @param _extraOptions Additional options passed by the caller.
* @return options The combination of caller specified options AND enforced options.
*
* @dev If there is an enforced lzReceive option:
* - {gasLimit: 200k, msg.value: 1 ether} AND a caller supplies a lzReceive option: {gasLimit: 100k, msg.value: 0.5 ether}
* - The resulting options will be {gasLimit: 300k, msg.value: 1.5 ether} when the message is executed on the remote lzReceive() function.
* @dev This presence of duplicated options is handled off-chain in the verifier/executor.
*/
function combineOptions(
uint32 _eid,
uint16 _msgType,
bytes calldata _extraOptions
) public view virtual returns (bytes memory) {
bytes memory enforced = enforcedOptions[_eid][_msgType];
// No enforced options, pass whatever the caller supplied, even if it's empty or legacy type 1/2 options.
if (enforced.length == 0) return _extraOptions;
// No caller options, return enforced
if (_extraOptions.length == 0) return enforced;
// @dev If caller provided _extraOptions, must be type 3 as its the ONLY type that can be combined.
if (_extraOptions.length >= 2) {
_assertOptionsType3(_extraOptions);
// @dev Remove the first 2 bytes containing the type from the _extraOptions and combine with enforced.
return bytes.concat(enforced, _extraOptions[2:]);
}
// No valid set of options was found.
revert InvalidOptions(_extraOptions);
}
/**
* @dev Internal function to assert that options are of type 3.
* @param _options The options to be checked.
*/
function _assertOptionsType3(bytes 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 { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { IPreCrime } from "./interfaces/IPreCrime.sol";
import { IOAppPreCrimeSimulator, InboundPacket, Origin } from "./interfaces/IOAppPreCrimeSimulator.sol";
/**
* @title OAppPreCrimeSimulator
* @dev Abstract contract serving as the base for preCrime simulation functionality in an OApp.
*/
abstract contract OAppPreCrimeSimulator is IOAppPreCrimeSimulator, Ownable {
// The address of the preCrime implementation.
address public preCrime;
/**
* @dev Retrieves the address of the OApp contract.
* @return The address of the OApp contract.
*
* @dev The simulator contract is the base contract for the OApp by default.
* @dev If the simulator is a separate contract, override this function.
*/
function oApp() external view virtual returns (address) {
return address(this);
}
/**
* @dev Sets the preCrime contract address.
* @param _preCrime The address of the preCrime contract.
*/
function setPreCrime(address _preCrime) public virtual onlyOwner {
preCrime = _preCrime;
emit PreCrimeSet(_preCrime);
}
/**
* @dev Interface for pre-crime simulations. Always reverts at the end with the simulation results.
* @param _packets An array of InboundPacket objects representing received packets to be delivered.
*
* @dev WARNING: MUST revert at the end with the simulation results.
* @dev Gives the preCrime implementation the ability to mock sending packets to the lzReceive function,
* WITHOUT actually executing them.
*/
function lzReceiveAndRevert(InboundPacket[] calldata _packets) public payable virtual {
for (uint256 i = 0; i < _packets.length; i++) {
InboundPacket calldata packet = _packets[i];
// Ignore packets that are not from trusted peers.
if (!isPeer(packet.origin.srcEid, packet.origin.sender)) continue;
// @dev Because a verifier is calling this function, it doesnt have access to executor params:
// - address _executor
// - bytes calldata _extraData
// preCrime will NOT work for OApps that rely on these two parameters inside of their _lzReceive().
// They are instead stubbed to default values, address(0) and bytes("")
// @dev Calling this.lzReceiveSimulate removes ability for assembly return 0 callstack exit,
// which would cause the revert to be ignored.
this.lzReceiveSimulate{ value: packet.value }(
packet.origin,
packet.guid,
packet.message,
packet.executor,
packet.extraData
);
}
// @dev Revert with the simulation results. msg.sender must implement IPreCrime.buildSimulationResult().
revert SimulationResult(IPreCrime(msg.sender).buildSimulationResult());
}
/**
* @dev Is effectively an internal function because msg.sender must be address(this).
* Allows resetting the call stack for 'internal' calls.
* @param _origin The origin information containing the source endpoint and sender address.
* - srcEid: The source chain endpoint ID.
* - sender: The sender address on the src chain.
* - nonce: The nonce of the message.
* @param _guid The unique identifier of the packet.
* @param _message The message payload of the packet.
* @param _executor The executor address for the packet.
* @param _extraData Additional data for the packet.
*/
function lzReceiveSimulate(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address _executor,
bytes calldata _extraData
) external payable virtual {
// @dev Ensure ONLY can be called 'internally'.
if (msg.sender != address(this)) revert OnlySelf();
_lzReceiveSimulate(_origin, _guid, _message, _executor, _extraData);
}
/**
* @dev Internal function to handle the OAppPreCrimeSimulator simulated receive.
* @param _origin The origin information.
* - srcEid: The source chain endpoint ID.
* - sender: The sender address from the src chain.
* - nonce: The nonce of the LayerZero message.
* @param _guid The GUID of the LayerZero message.
* @param _message The LayerZero message.
* @param _executor The address of the off-chain executor.
* @param _extraData Arbitrary data passed by the msg executor.
*
* @dev Enables the preCrime simulator to mock sending lzReceive() messages,
* routes the msg down from the OAppPreCrimeSimulator, and back up to the OAppReceiver.
*/
function _lzReceiveSimulate(
Origin calldata _origin,
bytes32 _guid,
bytes calldata _message,
address _executor,
bytes calldata _extraData
) internal virtual;
/**
* @dev checks if the specified peer is considered 'trusted' by the OApp.
* @param _eid The endpoint Id to check.
* @param _peer The peer to check.
* @return Whether the peer passed is considered 'trusted' by the OApp.
*/
function isPeer(uint32 _eid, bytes32 _peer) public view virtual returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSender.sol";
/**
* @dev Struct representing token parameters for the OFT send() operation.
*/
struct SendParam {
uint32 dstEid; // Destination endpoint ID.
bytes32 to; // Recipient address.
uint256 amountLD; // Amount to send in local decimals.
uint256 minAmountLD; // Minimum amount to send in local decimals.
bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
bytes composeMsg; // The composed message for the send() operation.
bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}
/**
* @dev Struct representing OFT limit information.
* @dev These amounts can change dynamically and are up the the specific oft implementation.
*/
struct OFTLimit {
uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}
/**
* @dev Struct representing OFT receipt information.
*/
struct OFTReceipt {
uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
// @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}
/**
* @dev Struct representing OFT fee details.
* @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
*/
struct OFTFeeDetail {
int256 feeAmountLD; // Amount of the fee in local decimals.
string description; // Description of the fee.
}
/**
* @title IOFT
* @dev Interface for the OftChain (OFT) token.
* @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
* @dev This specific interface ID is '0x02e49c2c'.
*/
interface IOFT {
// Custom error messages
error InvalidLocalDecimals();
error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);
// Events
event OFTSent(
bytes32 indexed guid, // GUID of the OFT message.
uint32 dstEid, // Destination Endpoint ID.
address indexed fromAddress, // Address of the sender on the src chain.
uint256 amountSentLD, // Amount of tokens sent in local decimals.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
event OFTReceived(
bytes32 indexed guid, // GUID of the OFT message.
uint32 srcEid, // Source Endpoint ID.
address indexed toAddress, // Address of the recipient on the dst chain.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
/**
* @notice Retrieves interfaceID and the version of the OFT.
* @return interfaceId The interface ID.
* @return version The version.
*
* @dev interfaceId: This specific interface ID is '0x02e49c2c'.
* @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
* @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
* ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
*/
function oftVersion() external view returns (bytes4 interfaceId, uint64 version);
/**
* @notice Retrieves the address of the token associated with the OFT.
* @return token The address of the ERC20 token implementation.
*/
function token() external view returns (address);
/**
* @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev Allows things like wallet implementers to determine integration requirements,
* without understanding the underlying token implementation.
*/
function approvalRequired() external view returns (bool);
/**
* @notice Retrieves the shared decimals of the OFT.
* @return sharedDecimals The shared decimals of the OFT.
*/
function sharedDecimals() external view returns (uint8);
/**
* @notice Provides a quote for OFT-related operations.
* @param _sendParam The parameters for the send operation.
* @return limit The OFT limit information.
* @return oftFeeDetails The details of OFT fees.
* @return receipt The OFT receipt information.
*/
function quoteOFT(
SendParam calldata _sendParam
) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory);
/**
* @notice Provides a quote for the send() operation.
* @param _sendParam The parameters for the send() operation.
* @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
* @return fee The calculated LayerZero messaging fee from the send() operation.
*
* @dev MessagingFee: LayerZero msg fee
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
*/
function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory);
/**
* @notice Executes the send() operation.
* @param _sendParam The parameters for the send operation.
* @param _fee The fee information supplied by the caller.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess funds from fees etc. on the src.
* @return receipt The LayerZero messaging receipt from the send() operation.
* @return oftReceipt The OFT receipt information.
*
* @dev MessagingReceipt: LayerZero msg receipt
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function send(
SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}// 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: 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 from 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 from 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
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
pragma solidity ^0.8.20;
import { IOAppReceiver, Origin } from "./interfaces/IOAppReceiver.sol";
import { OAppCore } from "./OAppCore.sol";
/**
* @title OAppReceiver
* @dev Abstract contract implementing the ILayerZeroReceiver interface and extending OAppCore for OApp receivers.
*/
abstract contract OAppReceiver is IOAppReceiver, OAppCore {
// Custom error message for when the caller is not the registered endpoint/
error OnlyEndpoint(address addr);
// @dev The version of the OAppReceiver implementation.
// @dev Version is bumped when changes are made to this contract.
uint64 internal constant RECEIVER_VERSION = 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 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 Retrieves the address responsible for 'sending' composeMsg's to the Endpoint.
* @return sender The address responsible for 'sending' composeMsg's to the Endpoint.
*
* @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer.
* @dev The default sender IS the OApp implementer.
*/
function composeMsgSender() public view virtual returns (address sender) {
return 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 { 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 {
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 v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// 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
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
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));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// 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 Retrieves the address responsible for 'sending' composeMsg's to the Endpoint.
* @return sender The address responsible for 'sending' composeMsg's to the Endpoint.
*
* @dev Applications can optionally choose to implement a separate composeMsg sender that is NOT the bridging layer.
* @dev The default sender IS the OApp implementer.
*/
function composeMsgSender() external view returns (address sender);
}// 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 v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// 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
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// 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 _timeout) external;
function defaultReceiveLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
function isSupportedEid(uint32 _eid) external view returns (bool);
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 _gracePeriod) external;
function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
function getConfig(
address _oapp,
address _lib,
uint32 _eid,
uint32 _configType
) external view returns (bytes memory config);
}// 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: 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
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
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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"LayerZero-v2/=lib/LayerZero-v2/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@layerzerolabs/lz-evm-protocol-v2/=lib/LayerZero-v2/protocol/",
"@layerzerolabs/lz-evm-messagelib-v2/=lib/LayerZero-v2/messagelib/",
"solidity-bytes-utils/=lib/solidity-bytes-utils/"
],
"optimizer": {
"enabled": true,
"runs": 1000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"uint256","name":"_initialSupplyERC20","type":"uint256"},{"internalType":"address","name":"_lzEndpoint","type":"address"},{"internalType":"address","name":"_delegate","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyExists","type":"error"},{"inputs":[],"name":"CannotRemoveFromWhitelist","type":"error"},{"inputs":[],"name":"DecimalsTooLow","type":"error"},{"inputs":[],"name":"InsufficientAllowance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidDelegate","type":"error"},{"inputs":[],"name":"InvalidEndpointCall","type":"error"},{"inputs":[],"name":"InvalidId","type":"error"},{"inputs":[],"name":"InvalidLocalDecimals","type":"error"},{"inputs":[],"name":"InvalidOperator","type":"error"},{"inputs":[{"internalType":"bytes","name":"options","type":"bytes"}],"name":"InvalidOptions","type":"error"},{"inputs":[],"name":"InvalidRecipient","type":"error"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"InvalidSpender","type":"error"},{"inputs":[],"name":"LzTokenUnavailable","type":"error"},{"inputs":[],"name":"MaxERC20SupplyReached","type":"error"},{"inputs":[],"name":"MaxERC721SupplyReached","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":"NotFound","type":"error"},{"inputs":[],"name":"NotWhitelisted","type":"error"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"OnlyEndpoint","type":"error"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"}],"name":"OnlyPeer","type":"error"},{"inputs":[],"name":"OnlySelf","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"SimulationResult","type":"error"},{"inputs":[{"internalType":"uint256","name":"amountLD","type":"uint256"},{"internalType":"uint256","name":"minAmountLD","type":"uint256"}],"name":"SlippageExceeded","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnsafeRecipient","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"valueOrId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"ERC20Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ERC20Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ERC721Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"ERC721Transfer","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"indexed":false,"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"EnforcedOptionSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"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":"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":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"valueOrId","type":"uint256"}],"name":"Transfer","type":"event"},{"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":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"approvalRequired","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"spender_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"uint16","name":"_msgType","type":"uint16"},{"internalType":"bytes","name":"_extraOptions","type":"bytes"}],"name":"combineOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"composeMsgSender","outputs":[{"internalType":"address","name":"sender","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimalConversionRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"endpoint","outputs":[{"internalType":"contract ILayerZeroEndpointV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"}],"name":"enforcedOptions","outputs":[{"internalType":"bytes","name":"enforcedOption","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc20BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"erc721BalanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_eid","type":"uint32"},{"internalType":"bytes32","name":"_peer","type":"bytes32"}],"name":"isPeer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"origin","type":"tuple"},{"internalType":"uint32","name":"dstEid","type":"uint32"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes32","name":"guid","type":"bytes32"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"executor","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"internalType":"struct InboundPacket[]","name":"_packets","type":"tuple[]"}],"name":"lzReceiveAndRevert","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"srcEid","type":"uint32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"internalType":"struct Origin","name":"_origin","type":"tuple"},{"internalType":"bytes32","name":"_guid","type":"bytes32"},{"internalType":"bytes","name":"_message","type":"bytes"},{"internalType":"address","name":"_executor","type":"address"},{"internalType":"bytes","name":"_extraData","type":"bytes"}],"name":"lzReceiveSimulate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"maxTotalSupplyERC20","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTotalSupplyERC721","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"msgInspector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"nftOwner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"}],"name":"peers","outputs":[{"internalType":"bytes32","name":"peer","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preCrime","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":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransferFrom","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":"operator_","type":"address"},{"internalType":"bool","name":"approved_","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_delegate","type":"address"}],"name":"setDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"uint16","name":"msgType","type":"uint16"},{"internalType":"bytes","name":"options","type":"bytes"}],"internalType":"struct EnforcedOptionParam[]","name":"_enforcedOptions","type":"tuple[]"}],"name":"setEnforcedOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"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":"address","name":"account_","type":"address"},{"internalType":"bool","name":"value_","type":"bool"}],"name":"setWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sharedDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"valueOrId_","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"units","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
610140604052601260c08190526200001990600a620009c0565b60e0523480156200002957600080fd5b5060405162005a3c38038062005a3c8339810160408190526200004c91620009f5565b6040518060400160405280600781526020016613d353924d0c0d60ca1b8152506040518060400160405280600481526020016313cd0c0d60e21b8152506032848460c051828281818181620000b0620000aa620001fd60201b60201c565b62000201565b6001600160a01b038083166080528116620000de57604051632d618d8160e21b815260040160405180910390fd5b60805160405163ca5eb5e160e01b81526001600160a01b0383811660048301529091169063ca5eb5e190602401600060405180830381600087803b1580156200012657600080fd5b505af11580156200013b573d6000803e3d6000fd5b5050505050505050620001536200025160201b60201c565b60ff168360ff1610156200017a576040516301e9714b60e41b815260040160405180910390fd5b6200018760068462000a36565b6200019490600a620009c0565b60a0525060079150620001aa9050868262000af8565b506008620001b9858262000af8565b5061012083905260e051620001cf908462000bc4565b6101005250620001e89350849250600191505062000256565b620001f48184620002c9565b50505062000c75565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600690565b60e0516001600160a01b0383166000908152600b6020526040902054101580156200027f575080155b156200029e57604051633c3d8d2560e11b815260040160405180910390fd5b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b6001600160a01b038216620002f157604051634e46966960e11b815260040160405180910390fd5b6001600160a01b0382166000908152600b60205260408120549062000318908484620003a9565b6001600160a01b03831660009081526012602052604090205460ff16620003a457600060e051826200034b919062000bde565b60e0516001600160a01b0386166000908152600b602052604090205462000373919062000bde565b6200037f919062000c01565b905060005b81811015620003a15762000398856200052e565b60010162000384565b50505b505050565b6001600160a01b038316620003fa576101005181600954620003cc919062000c17565b1115620003ec5760405163014d590160e11b815260040160405180910390fd5b60098054820190556200047c565b6001600160a01b0383166000908152600b60205260409020548111156200043457604051631e9acf1760e31b815260040160405180910390fd5b6001600160a01b0383166000908152600b6020526040812080548392906200045e90849062000c01565b90915550506001600160a01b0382166200047c576009805482900390555b6001600160a01b03821615620004ab576001600160a01b0382166000908152600b602052604090208054820190555b80826001600160a01b0316846001600160a01b031660008051602062005a1c83398151915260405160405180910390a4816001600160a01b0316836001600160a01b03167fe59fdd36d0d223c0c7d996db7ad796880f45e1936cb0bb7ac102e7082e031487836040516200052191815260200190565b60405180910390a3505050565b6001600160a01b03811615806200054d57506001600160a01b03811630145b156200056c57604051634e46966960e11b815260040160405180910390fd5b60006200058d600554600160801b81046001600160801b0390811691161490565b620005a6576200059e600562000646565b9050620005e9565b600a8054906000620005b88362000c2d565b9190505550600a54905061012051600a541115620005e9576040516377a4ae0960e01b815260040160405180910390fd5b6000818152600f60205260409020546001600160a01b031680158015906200061a57506001600160a01b0381163014155b15620006395760405163119b4fd360e11b815260040160405180910390fd5b620003a4818484620006aa565b80546000906001600160801b03600160801b8204811691168103620006715762000671603162000896565b600019016001600160801b039081166000818152600185016020526040812080549190558454909216600160801b909102179092555090565b6001600160a01b03831615620007bd576000818152600d6020908152604080832080546001600160a01b03191690556001600160a01b0386168352601090915281208054620006fc9060019062000c01565b815481106200070f576200070f62000c49565b60009182526020808320909101546001600160a01b038716835260108252604080842086855260119093529092205481549293508392811062000756576200075662000c49565b60009182526020808320909101929092556001600160a01b03861681526010909152604090208054806200078e576200078e62000c5f565b600082815260208082208301600019908101839055909201909255838252601190526040808220549282529020555b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b03871690811790915580845260108352908320805460018181018355828652938520018590559252905462000817919062000c01565b60008281526011602052604080822092909255905182916001600160a01b03808616929087169160008051602062005a1c83398151915291a480826001600160a01b0316846001600160a01b03167fe5f815dc84b8cecdfd4beedfc3f91ab5be7af100eca4e8fb11552b867995394f60405160405180910390a4505050565b634e487b7160e01b6000528060045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600181815b8085111562000902578160001904821115620008e657620008e6620008ab565b80851615620008f457918102915b93841c9390800290620008c6565b509250929050565b6000826200091b57506001620009ba565b816200092a57506000620009ba565b81600181146200094357600281146200094e576200096e565b6001915050620009ba565b60ff841115620009625762000962620008ab565b50506001821b620009ba565b5060208310610133831016604e8410600b841016171562000993575081810a620009ba565b6200099f8383620008c1565b8060001904821115620009b657620009b6620008ab565b0290505b92915050565b6000620009d160ff8416836200090a565b9392505050565b80516001600160a01b0381168114620009f057600080fd5b919050565b60008060006060848603121562000a0b57600080fd5b8351925062000a1d60208501620009d8565b915062000a2d60408501620009d8565b90509250925092565b60ff8281168282160390811115620009ba57620009ba620008ab565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168062000a7d57607f821691505b60208210810362000a9e57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003a4576000816000526020600020601f850160051c8101602086101562000acf5750805b601f850160051c820191505b8181101562000af05782815560010162000adb565b505050505050565b81516001600160401b0381111562000b145762000b1462000a52565b62000b2c8162000b25845462000a68565b8462000aa4565b602080601f83116001811462000b64576000841562000b4b5750858301515b600019600386901b1c1916600185901b17855562000af0565b600085815260208120601f198616915b8281101562000b955788860151825594840194600190910190840162000b74565b508582101562000bb45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b8082028115828204841417620009ba57620009ba620008ab565b60008262000bfc57634e487b7160e01b600052601260045260246000fd5b500490565b81810381811115620009ba57620009ba620008ab565b80820180821115620009ba57620009ba620008ab565b60006001820162000c425762000c42620008ab565b5060010190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b60805160a05160c05160e0516101005161012051614c9a62000d82600039600081816108a501528181610c970152818161107f015281816114530152818161162d015261307901526000818161067801526122960152600081816109220152818161116401528181611691015281816126bf015281816126e901528181612760015281816127a401528181612a7a01528181613276015281816132a00152818161349c01526134e0015260006105c50152600081816108ee01528181612e1901528181612e8e015261314a01526000818161076c01528181610f6401528181611e98015281816121b4015281816129ad01528181612c080152818161333201526134040152614c9a6000f3fe60806040526004361061038c5760003560e01c8063715018a6116101dc578063b92d0eff11610102578063ca5eb5e1116100a0578063e985e9c51161006f578063e985e9c514610b8a578063f2fde38b14610bc5578063fc0c546a146106b0578063ff7bd03d14610be557600080fd5b8063ca5eb5e114610aff578063d045a0dc14610b1f578063d424388514610b32578063dd62ed3e14610b5257600080fd5b8063bc70b354116100dc578063bc70b35414610a8b578063bd815db014610aab578063c7c7f5b314610abe578063c87b56dd14610adf57600080fd5b8063b92d0eff146106b0578063b98bd07014610a3e578063bb0b6a5314610a5e57600080fd5b8063976a84351161017a578063a9059cbb11610149578063a9059cbb146109a8578063b3f9ea34146109c8578063b731ea0a146109fe578063b88d4fde14610a1e57600080fd5b8063976a8435146109105780639b19251a146109445780639f68b96414610974578063a22cb4651461098857600080fd5b80638da5cb5b116101b65780638da5cb5b14610875578063922c36c31461089357806395d89b41146108c7578063963efcaa146108dc57600080fd5b8063715018a6146108105780637d25a05e14610825578063857749b01461086157600080fd5b80633400288b116102c15780635535d4611161025f5780636352211e1161022e5780636352211e1461078e5780636c0360eb146107ae5780636fc1b31e146107c357806370a08231146107e357600080fd5b80635535d461146106e357806355f804b3146107035780635a0dfe4d146107235780635e280f111461075a57600080fd5b80634b63babb1161029b5780634b63babb146106665780634f02c4201461069a57806352ae2879146106b057806353d6fd59146106c357600080fd5b80633400288b146105f95780633b6f743b1461061957806342842e0e1461064657600080fd5b8063134d4f251161032e57806318160ddd1161030857806318160ddd146105685780631f5e13341461057e57806323b872dd14610593578063313ce567146105b357600080fd5b8063134d4f25146104de578063156a0d0f1461050657806317442b701461054757600080fd5b8063095ea7b31161036a578063095ea7b31461044a5780630d35b4151461047a578063111ecdad146104a957806313137d65146104c957600080fd5b806302519da31461039157806306fdde03146103da578063081812fc146103fc575b600080fd5b34801561039d57600080fd5b506103c76103ac36600461390e565b6001600160a01b03166000908152600b602052604090205490565b6040519081526020015b60405180910390f35b3480156103e657600080fd5b506103ef610c05565b6040516103d1919061397b565b34801561040857600080fd5b5061043261041736600461398e565b600d602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103d1565b34801561045657600080fd5b5061046a6104653660046139a7565b610c93565b60405190151581526020016103d1565b34801561048657600080fd5b5061049a6104953660046139eb565b610e90565b6040516103d193929190613a20565b3480156104b557600080fd5b50600454610432906001600160a01b031681565b6104dc6104d7366004613b14565b610f62565b005b3480156104ea57600080fd5b506104f3600281565b60405161ffff90911681526020016103d1565b34801561051257600080fd5b50604080517f02e49c2c00000000000000000000000000000000000000000000000000000000815260016020820152016103d1565b34801561055357600080fd5b506040805160018082526020820152016103d1565b34801561057457600080fd5b506103c760095481565b34801561058a57600080fd5b506104f3600181565b34801561059f57600080fd5b5061046a6105ae366004613bb4565b611054565b3480156105bf57600080fd5b506105e77f000000000000000000000000000000000000000000000000000000000000000081565b60405160ff90911681526020016103d1565b34801561060557600080fd5b506104dc610614366004613c09565b61124b565b34801561062557600080fd5b50610639610634366004613c33565b6112a9565b6040516103d19190613c85565b34801561065257600080fd5b506104dc610661366004613bb4565b611310565b34801561067257600080fd5b506103c77f000000000000000000000000000000000000000000000000000000000000000081565b3480156106a657600080fd5b506103c7600a5481565b3480156106bc57600080fd5b5030610432565b3480156106cf57600080fd5b506104dc6106de366004613c9c565b6113eb565b3480156106ef57600080fd5b506103ef6106fe366004613cdc565b611401565b34801561070f57600080fd5b506104dc61071e366004613da7565b611425565b34801561072f57600080fd5b5061046a61073e366004613c09565b63ffffffff919091166000908152600160205260409020541490565b34801561076657600080fd5b506104327f000000000000000000000000000000000000000000000000000000000000000081565b34801561079a57600080fd5b506104326107a936600461398e565b611439565b3480156107ba57600080fd5b506103ef6114cb565b3480156107cf57600080fd5b506104dc6107de36600461390e565b6114d8565b3480156107ef57600080fd5b506103c76107fe36600461390e565b600b6020526000908152604090205481565b34801561081c57600080fd5b506104dc611535565b34801561083157600080fd5b50610848610840366004613c09565b600092915050565b60405167ffffffffffffffff90911681526020016103d1565b34801561086d57600080fd5b5060066105e7565b34801561088157600080fd5b506000546001600160a01b0316610432565b34801561089f57600080fd5b506103c77f000000000000000000000000000000000000000000000000000000000000000081565b3480156108d357600080fd5b506103ef611549565b3480156108e857600080fd5b506103c77f000000000000000000000000000000000000000000000000000000000000000081565b34801561091c57600080fd5b506103c77f000000000000000000000000000000000000000000000000000000000000000081565b34801561095057600080fd5b5061046a61095f36600461390e565b60126020526000908152604090205460ff1681565b34801561098057600080fd5b50600061046a565b34801561099457600080fd5b506104dc6109a3366004613c9c565b611556565b3480156109b457600080fd5b5061046a6109c33660046139a7565b611602565b3480156109d457600080fd5b506103c76109e336600461390e565b6001600160a01b031660009081526010602052604090205490565b348015610a0a57600080fd5b50600254610432906001600160a01b031681565b348015610a2a57600080fd5b506104dc610a39366004613e27565b6116dd565b348015610a4a57600080fd5b506104dc610a59366004613edf565b6117a8565b348015610a6a57600080fd5b506103c7610a79366004613f21565b60016020526000908152604090205481565b348015610a9757600080fd5b506103ef610aa6366004613f3c565b611909565b6104dc610ab9366004613edf565b611a84565b610ad1610acc366004613f9d565b611c27565b6040516103d192919061400b565b348015610aeb57600080fd5b506103ef610afa36600461398e565b611d21565b348015610b0b57600080fd5b506104dc610b1a36600461390e565b611e58565b6104dc610b2d366004613b14565b611ef0565b348015610b3e57600080fd5b506104dc610b4d36600461390e565b611f38565b348015610b5e57600080fd5b506103c7610b6d36600461405e565b600c60209081526000928352604080842090915290825290205481565b348015610b9657600080fd5b5061046a610ba536600461405e565b600e60209081526000928352604080842090915290825290205460ff1681565b348015610bd157600080fd5b506104dc610be036600461390e565b611f8e565b348015610bf157600080fd5b5061046a610c0036600461408c565b61201e565b60078054610c12906140a8565b80601f0160208091040260200160405190810160405280929190818152602001828054610c3e906140a8565b8015610c8b5780601f10610c6057610100808354040283529160200191610c8b565b820191906000526020600020905b815481529060010190602001808311610c6e57829003601f168201915b505050505081565b60007f00000000000000000000000000000000000000000000000000000000000000008211158015610cc55750600082115b15610de0576000828152600f602052604090205482906001600160a01b0316338114801590610d1857506001600160a01b0381166000908152600e6020908152604080832033845290915290205460ff16155b15610d35576040516282b42960e81b815260040160405180910390fd5b6000828152600d602090815260409182902080546001600160a01b0319166001600160a01b038981169182179092559251858152908416917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a381856001600160a01b0316826001600160a01b03167f797365dabb18fa726ccbccbe18c6f24c34e3b0653f2e99ea873bd7b84763dde660405160405180910390a45050610e86565b336000818152600c602090815260408083206001600160a01b03881680855290835292819020869055518581528593917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3604080513381526001600160a01b03861660208201529081018290527f1f01303a1ce9329d9963e1937c201e23c5543a9e3536e9edead087aec7dc6d839060600160405180910390a1505b5060015b92915050565b60408051808201909152600080825260208201526060610ec3604051806040016040528060008152602001600081525090565b604080518082018252600080825267ffffffffffffffff602080840182905284518381529081019094529195509182610f1f565b604080518082019091526000815260606020820152815260200190600190039081610ef75790505b509350600080610f44604089013560608a0135610f3f60208c018c613f21565b612054565b60408051808201909152918252602082015296989597505050505050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163314610fcb576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b60208701803590610fe590610fe0908a613f21565b6120b1565b1461103c57610ff76020880188613f21565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff909116600482015260208801356024820152604401610fc2565b61104b87878787878787612106565b50505050505050565b60006001600160a01b03831661107d57604051634e46966960e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000008211611199576000828152600f602052604090205482906001600160a01b038681169116146110e057604051636edaef2f60e11b815260040160405180910390fd5b336001600160a01b0386161480159061111d57506001600160a01b0385166000908152600e6020908152604080832033845290915290205460ff16155b801561114057506000818152600d60205260409020546001600160a01b03163314155b1561115d576040516282b42960e81b815260040160405180910390fd5b61118885857f0000000000000000000000000000000000000000000000000000000000000000612286565b611193858583612460565b50611240565b6001600160a01b0384166000908152600c60209081526040808320338452909152902054829060001981146112315781811015611202576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61120c82826140f2565b6001600160a01b0387166000908152600c602090815260408083203384529091529020555b61123c86868461264f565b5050505b5060015b9392505050565b611253612800565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b91015b60405180910390a15050565b604080518082019091526000808252602082015260006112d960408501356060860135610f3f6020880188613f21565b9150506000806112e9868461285a565b90925090506113066112fe6020880188613f21565b838388612997565b9695505050505050565b61131b838383611054565b506001600160a01b0382163b158015906113c85750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015611397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bb9190614105565b6001600160e01b03191614155b156113e657604051633da6393160e01b815260040160405180910390fd5b505050565b6113f3612800565b6113fd8282612a78565b5050565b600360209081526000928352604080842090915290825290208054610c12906140a8565b61142d612800565b60136113fd828261417f565b6000818152600f60205260409020546001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000082118061147d575081155b8061148f57506001600160a01b038116155b156114c6576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60138054610c12906140a8565b6114e0612800565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197906020015b60405180910390a150565b61153d612800565b6115476000612b26565b565b60088054610c12906140a8565b6001600160a01b038216611596576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600e602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b03831661162b57604051634e46966960e11b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000082116116c6576000828152600f602052604090205482906001600160a01b0316331461168a576040516282b42960e81b815260040160405180910390fd5b6116b533857f0000000000000000000000000000000000000000000000000000000000000000612286565b6116c0338583612460565b50610e86565b816116d233858361264f565b505050600192915050565b6116e8858585611054565b506001600160a01b0384163b158015906117835750604051630a85bd0160e11b808252906001600160a01b0386169063150b7a02906117339033908a90899089908990600401614268565b6020604051808303816000875af1158015611752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117769190614105565b6001600160e01b03191614155b156117a157604051633da6393160e01b815260040160405180910390fd5b5050505050565b6117b0612800565b60005b818110156118d7576117f58383838181106117d0576117d061429b565b90506020028101906117e291906142b1565b6117f09060408101906142d1565b612b76565b8282828181106118075761180761429b565b905060200281019061181991906142b1565b6118279060408101906142d1565b6003600086868681811061183d5761183d61429b565b905060200281019061184f91906142b1565b61185d906020810190613f21565b63ffffffff1663ffffffff168152602001908152602001600020600086868681811061188b5761188b61429b565b905060200281019061189d91906142b1565b6118ae906040810190602001614318565b61ffff1681526020810191909152604001600020916118ce919083614333565b506001016117b3565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b674828260405161129d9291906143f3565b63ffffffff8416600090815260036020908152604080832061ffff8716845290915281208054606092919061193d906140a8565b80601f0160208091040260200160405190810160405280929190818152602001828054611969906140a8565b80156119b65780601f1061198b576101008083540402835291602001916119b6565b820191906000526020600020905b81548152906001019060200180831161199957829003601f168201915b505050505090508051600003611a065783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929450611a7c9350505050565b6000839003611a16579050611a7c565b60028310611a5f57611a288484612b76565b80611a3684600281886144d8565b604051602001611a4893929190614502565b604051602081830303815290604052915050611a7c565b8383604051639a6d49cd60e01b8152600401610fc292919061452a565b949350505050565b60005b81811015611b8d5736838383818110611aa257611aa261429b565b9050602002810190611ab4919061453e565b9050611ae7611ac66020830183613f21565b602083013563ffffffff919091166000908152600160205260409020541490565b611af15750611b85565b3063d045a0dc60c08301358360a0810135611b106101008301836142d1565b611b21610100890160e08a0161390e565b611b2f6101208a018a6142d1565b6040518963ffffffff1660e01b8152600401611b51979695949392919061456b565b6000604051808303818588803b158015611b6a57600080fd5b505af1158015611b7e573d6000803e3d6000fd5b5050505050505b600101611a87565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611bcc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bf491908101906145f2565b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152600401610fc2919061397b565b611c2f6138b1565b6040805180820190915260008082526020820152600080611c6560408801356060890135611c6060208b018b613f21565b612bb8565b91509150600080611c76898461285a565b9092509050611ca2611c8b60208b018b613f21565b8383611c9c368d90038d018d614660565b8b612bd5565b60408051808201909152858152602080820186905282519298509096503391907f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a90611cf0908d018d613f21565b6040805163ffffffff909216825260208201899052810187905260600160405180910390a350505050935093915050565b60606000611d2e83612ce0565b604051602001611d3e9190614692565b60405160208183030381529060405290506000611d5a84612ce0565b604051602001611d6a91906146d3565b60408051601f1981840301815290829052611d8791602001614718565b604051602081830303815290604052601383604051602001611daa9291906147cb565b60408051601f1981840301815290829052611dc89291602001614852565b60408051808303601f190181528282527f227d00000000000000000000000000000000000000000000000000000000000060208401528151600281850301815260228401909252925090611e229083908390604201614852565b60408051601f1981840301815290829052611e3f91602001614878565b6040516020818303038152906040529350505050919050565b611e60612800565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ca5eb5e190602401600060405180830381600087803b158015611edc57600080fd5b505af11580156117a1573d6000803e3d6000fd5b333014611f29576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104b8787878787878761103c565b611f40612800565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c24277609060200161152a565b611f96612800565b6001600160a01b0381166120125760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610fc2565b61201b81612b26565b50565b60006020820180359060019083906120369086613f21565b63ffffffff1681526020810191909152604001600020541492915050565b60008061206085612e15565b9150819050838110156120a9576040517f71c4efed0000000000000000000000000000000000000000000000000000000081526004810182905260248101859052604401610fc2565b935093915050565b63ffffffff811660009081526001602052604081205480610e8a576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff84166004820152602401610fc2565b60006121186121158787612e4c565b90565b905060006121448261213261212d8a8a612e64565b612e87565b61213f60208d018d613f21565b612ebd565b9050602886111561222457600061218161216460608c0160408d016148bd565b61217160208d018d613f21565b8461217c8c8c612ed1565b612f1c565b6040517f7cb590120000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690637cb59012906121f09086908d9060009087906004016148da565b600060405180830381600087803b15801561220a57600080fd5b505af115801561221e573d6000803e3d6000fd5b50505050505b6001600160a01b038216887fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c61225d60208d018d613f21565b6040805163ffffffff9092168252602082018690520160405180910390a3505050505050505050565b6001600160a01b038316612308577f0000000000000000000000000000000000000000000000000000000000000000816009546122c3919061490c565b11156122fb576040517f029ab20200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600980548201905561239f565b6001600160a01b0383166000908152600b602052604090205481111561235a576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383166000908152600b6020526040812080548392906123829084906140f2565b90915550506001600160a01b03821661239f576009805482900390555b6001600160a01b038216156123cd576001600160a01b0382166000908152600b602052604090208054820190555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4816001600160a01b0316836001600160a01b03167fe59fdd36d0d223c0c7d996db7ad796880f45e1936cb0bb7ac102e7082e0314878360405161245391815260200190565b60405180910390a3505050565b6001600160a01b03831615612567576000818152600d6020908152604080832080546001600160a01b03191690556001600160a01b03861683526010909152812080546124af906001906140f2565b815481106124bf576124bf61429b565b60009182526020808320909101546001600160a01b03871683526010825260408084208685526011909352909220548154929350839281106125035761250361429b565b60009182526020808320909101929092556001600160a01b03861681526010909152604090208054806125385761253861491f565b600082815260208082208301600019908101839055909201909255838252601190526040808220549282529020555b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b0387169081179091558084526010835290832080546001818101835582865293852001859055925290546125bf91906140f2565b60008281526011602052604080822092909255905182916001600160a01b0380861692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a480826001600160a01b0316846001600160a01b03167fe5f815dc84b8cecdfd4beedfc3f91ab5be7af100eca4e8fb11552b867995394f60405160405180910390a4505050565b6001600160a01b038381166000908152600b6020526040808220549285168252812054909190612680868686612286565b6001600160a01b03861660009081526012602052604090205460ff16612739576001600160a01b0386166000908152600b60205260408120546126e4907f00000000000000000000000000000000000000000000000000000000000000009061494b565b61270e7f00000000000000000000000000000000000000000000000000000000000000008561494b565b61271891906140f2565b905060005b818110156127365761272e88612f4e565b60010161271d565b50505b6001600160a01b03851660009081526012602052604090205460ff166127f45760006127857f00000000000000000000000000000000000000000000000000000000000000008361494b565b6001600160a01b0387166000908152600b60205260409020546127c9907f00000000000000000000000000000000000000000000000000000000000000009061494b565b6127d391906140f2565b905060005b818110156127f1576127e987612fe3565b6001016127d8565b50505b50600195945050505050565b6000546001600160a01b031633146115475760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fc2565b60608060006128b7856020013561287086613143565b61287d60a08901896142d1565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061316f92505050565b90935090506000816128ca5760016128cd565b60025b90506128ed6128df6020880188613f21565b82610aa660808a018a6142d1565b6004549093506001600160a01b03161561298e57600480546040517f043a78eb0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169163043a78eb9161294b91889188910161495f565b602060405180830381865afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c9190614984565b505b50509250929050565b60408051808201909152600080825260208201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020016129fa896120b1565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b8152600401612a2f9291906149a1565b6040805180830381865afa158015612a4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6f9190614a4a565b95945050505050565b7f0000000000000000000000000000000000000000000000000000000000000000612ab8836001600160a01b03166000908152600b602052604090205490565b10158015612ac4575080155b15612afb576040517f787b1a4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612b8560028284866144d8565b612b8e91614a66565b60f01c9050600381146113e6578282604051639a6d49cd60e01b8152600401610fc292919061452a565b600080612bc6858585612054565b90925090506120a933836131e9565b612bdd6138b1565b6000612bec84600001516132ed565b602085015190915015612c0657612c06846020015161332e565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001612c568c6120b1565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401612c929291906149a1565b60806040518083038185885af1158015612cb0573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612cd59190614aae565b979650505050505050565b606081600003612d2357505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612d4d5780612d3781614b16565b9150612d469050600a8361494b565b9150612d27565b60008167ffffffffffffffff811115612d6857612d68613d0f565b6040519080825280601f01601f191660200182016040528015612d92576020820181803683370190505b5090505b8415611a7c57612da76001836140f2565b9150612db4600a86614b2f565b612dbf90603061490c565b60f81b818381518110612dd457612dd461429b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612e0e600a8661494b565b9450612d96565b60007f0000000000000000000000000000000000000000000000000000000000000000612e42818461494b565b610e8a9190614b43565b6000612e5b60208284866144d8565b61124491614b5a565b6000612e746028602084866144d8565b612e7d91614b78565b60c01c9392505050565b6000610e8a7f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff8416614b43565b6000612ec98484613429565b509092915050565b6060612ee082602881866144d8565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929695505050505050565b606084848484604051602001612f359493929190614ba6565b6040516020818303038152906040529050949350505050565b6001600160a01b0381161580612f6c57506001600160a01b03811630145b15612f8a57604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b03811660009081526010602052604081208054612fb0906001906140f2565b81548110612fc057612fc061429b565b90600052602060002001549050612fd8823083612460565b6113fd60058261352d565b6001600160a01b038116158061300157506001600160a01b03811630145b1561301f57604051634e46966960e11b815260040160405180910390fd5b6000613048600554600160801b81046fffffffffffffffffffffffffffffffff90811691161490565b61305d5761305660056135b2565b90506130d1565b600a805490600061306d83614b16565b9091555050600a5490507f00000000000000000000000000000000000000000000000000000000000000008111156130d1576040517f77a4ae0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600f60205260409020546001600160a01b0316801580159061310157506001600160a01b0381163014155b15613138576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e6818484612460565b6000610e8a7f00000000000000000000000000000000000000000000000000000000000000008361494b565b80516060901515806131b85784846040516020016131a492919091825260c01b6001600160c01b031916602082015260280190565b6040516020818303038152906040526131df565b848433856040516020016131cf9493929190614bf4565b6040516020818303038152906040525b9150935093915050565b6001600160a01b03821661321057604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600b6020526040812054905061323783600084612286565b6001600160a01b03831660009081526012602052604090205460ff166113e6576001600160a01b0383166000908152600b602052604081205461329b907f00000000000000000000000000000000000000000000000000000000000000009061494b565b6132c57f00000000000000000000000000000000000000000000000000000000000000008461494b565b6132cf91906140f2565b905060005b818110156117a1576132e585612f4e565b6001016132d4565b600081341461332a576040517f9f704120000000000000000000000000000000000000000000000000000000008152346004820152602401610fc2565b5090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663e4fe1d946040518163ffffffff1660e01b8152600401602060405180830381865afa15801561338e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b29190614c35565b90506001600160a01b0381166133f4576040517f5373352a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113fd6001600160a01b038216337f000000000000000000000000000000000000000000000000000000000000000085613625565b6001600160a01b03821661345057604051634e46966960e11b815260040160405180910390fd5b6001600160a01b0382166000908152600b602052604081205490613475908484612286565b6001600160a01b03831660009081526012602052604090205460ff166113e65760006134c17f00000000000000000000000000000000000000000000000000000000000000008361494b565b6001600160a01b0385166000908152600b6020526040902054613505907f00000000000000000000000000000000000000000000000000000000000000009061494b565b61350f91906140f2565b905060005b818110156117a15761352585612fe3565b600101613514565b81546fffffffffffffffffffffffffffffffff8082166000190191600160801b90048116908216036135635761356360416136b3565b6fffffffffffffffffffffffffffffffff16600081815260018401602052604090209190915581547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016179055565b80546000906fffffffffffffffffffffffffffffffff600160801b82048116911681036135e3576135e360316136b3565b600019016fffffffffffffffffffffffffffffffff9081166000818152600185016020526040812080549190558454909216600160801b909102179092555090565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526136ad9085906136c8565b50505050565b634e487b7160e01b6000528060045260246000fd5b600061371d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137ad9092919063ffffffff16565b8051909150156113e6578080602001905181019061373b9190614984565b6113e65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610fc2565b6060611a7c8484600085856001600160a01b0385163b61380f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc2565b600080866001600160a01b0316858760405161382b9190614c52565b60006040518083038185875af1925050503d8060008114613868576040519150601f19603f3d011682016040523d82523d6000602084013e61386d565b606091505b5091509150612cd582828660608315613887575081611244565b8251156138975782518084602001fd5b8160405162461bcd60e51b8152600401610fc2919061397b565b604051806060016040528060008019168152602001600067ffffffffffffffff1681526020016138f4604051806040016040528060008152602001600081525090565b905290565b6001600160a01b038116811461201b57600080fd5b60006020828403121561392057600080fd5b8135611244816138f9565b60005b8381101561394657818101518382015260200161392e565b50506000910152565b6000815180845261396781602086016020860161392b565b601f01601f19169290920160200192915050565b602081526000611244602083018461394f565b6000602082840312156139a057600080fd5b5035919050565b600080604083850312156139ba57600080fd5b82356139c5816138f9565b946020939093013593505050565b600060e082840312156139e557600080fd5b50919050565b6000602082840312156139fd57600080fd5b813567ffffffffffffffff811115613a1457600080fd5b611a7c848285016139d3565b8351815260208085015190820152600060a08201604060a0604085015281865180845260c08601915060c08160051b8701019350602080890160005b83811015613a9b5788870360bf19018552815180518852830151838801879052613a888789018261394f565b9750509382019390820190600101613a5c565b50508751606088015250505060208501516080850152509050611a7c565b6000606082840312156139e557600080fd5b60008083601f840112613add57600080fd5b50813567ffffffffffffffff811115613af557600080fd5b602083019150836020828501011115613b0d57600080fd5b9250929050565b600080600080600080600060e0888a031215613b2f57600080fd5b613b398989613ab9565b965060608801359550608088013567ffffffffffffffff80821115613b5d57600080fd5b613b698b838c01613acb565b909750955060a08a01359150613b7e826138f9565b90935060c08901359080821115613b9457600080fd5b50613ba18a828b01613acb565b989b979a50959850939692959293505050565b600080600060608486031215613bc957600080fd5b8335613bd4816138f9565b92506020840135613be4816138f9565b929592945050506040919091013590565b803563ffffffff811681146114c657600080fd5b60008060408385031215613c1c57600080fd5b6139c583613bf5565b801515811461201b57600080fd5b60008060408385031215613c4657600080fd5b823567ffffffffffffffff811115613c5d57600080fd5b613c69858286016139d3565b9250506020830135613c7a81613c25565b809150509250929050565b815181526020808301519082015260408101610e8a565b60008060408385031215613caf57600080fd5b8235613cba816138f9565b91506020830135613c7a81613c25565b803561ffff811681146114c657600080fd5b60008060408385031215613cef57600080fd5b613cf883613bf5565b9150613d0660208401613cca565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613d4857613d48613d0f565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613d7757613d77613d0f565b604052919050565b600067ffffffffffffffff821115613d9957613d99613d0f565b50601f01601f191660200190565b600060208284031215613db957600080fd5b813567ffffffffffffffff811115613dd057600080fd5b8201601f81018413613de157600080fd5b8035613df4613def82613d7f565b613d4e565b818152856020838501011115613e0957600080fd5b81602084016020830137600091810160200191909152949350505050565b600080600080600060808688031215613e3f57600080fd5b8535613e4a816138f9565b94506020860135613e5a816138f9565b935060408601359250606086013567ffffffffffffffff811115613e7d57600080fd5b613e8988828901613acb565b969995985093965092949392505050565b60008083601f840112613eac57600080fd5b50813567ffffffffffffffff811115613ec457600080fd5b6020830191508360208260051b8501011115613b0d57600080fd5b60008060208385031215613ef257600080fd5b823567ffffffffffffffff811115613f0957600080fd5b613f1585828601613e9a565b90969095509350505050565b600060208284031215613f3357600080fd5b61124482613bf5565b60008060008060608587031215613f5257600080fd5b613f5b85613bf5565b9350613f6960208601613cca565b9250604085013567ffffffffffffffff811115613f8557600080fd5b613f9187828801613acb565b95989497509550505050565b60008060008385036080811215613fb357600080fd5b843567ffffffffffffffff811115613fca57600080fd5b613fd6878288016139d3565b9450506040601f1982011215613feb57600080fd5b506020840191506060840135614000816138f9565b809150509250925092565b600060c0820190508351825267ffffffffffffffff60208501511660208301526040840151614047604084018280518252602090810151910152565b5082516080830152602083015160a0830152611244565b6000806040838503121561407157600080fd5b823561407c816138f9565b91506020830135613c7a816138f9565b60006060828403121561409e57600080fd5b6112448383613ab9565b600181811c908216806140bc57607f821691505b6020821081036139e557634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610e8a57610e8a6140dc565b60006020828403121561411757600080fd5b81516001600160e01b03198116811461124457600080fd5b601f8211156113e6576000816000526020600020601f850160051c810160208610156141585750805b601f850160051c820191505b8181101561417757828155600101614164565b505050505050565b815167ffffffffffffffff81111561419957614199613d0f565b6141ad816141a784546140a8565b8461412f565b602080601f8311600181146141e257600084156141ca5750858301515b600019600386901b1c1916600185901b178555614177565b600085815260208120601f198616915b82811015614211578886015182559484019460019091019084016141f2565b508582101561422f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152612cd560808301848661423f565b634e487b7160e01b600052603260045260246000fd5b60008235605e198336030181126142c757600080fd5b9190910192915050565b6000808335601e198436030181126142e857600080fd5b83018035915067ffffffffffffffff82111561430357600080fd5b602001915036819003821315613b0d57600080fd5b60006020828403121561432a57600080fd5b61124482613cca565b67ffffffffffffffff83111561434b5761434b613d0f565b61435f8361435983546140a8565b8361412f565b6000601f841160018114614393576000851561437b5750838201355b600019600387901b1c1916600186901b1783556117a1565b600083815260209020601f19861690835b828110156143c457868501358255602094850194600190920191016143a4565b50868210156143e15760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208082528181018390526000906040808401600586901b8501820187855b888110156144ca57878303603f190184528135368b9003605e1901811261443857600080fd5b8a01606063ffffffff61444a83613bf5565b16855261ffff61445b898401613cca565b168886015286820135601e1983360301811261447657600080fd5b90910187810191903567ffffffffffffffff81111561449457600080fd5b8036038313156144a357600080fd5b81888701526144b5828701828561423f565b96890196955050509186019150600101614412565b509098975050505050505050565b600080858511156144e857600080fd5b838611156144f557600080fd5b5050820193919092039150565b6000845161451481846020890161392b565b8201838582376000930192835250909392505050565b602081526000611a7c60208301848661423f565b6000823561013e198336030181126142c757600080fd5b67ffffffffffffffff8116811461201b57600080fd5b63ffffffff61457989613bf5565b168152602088013560208201526000604089013561459681614555565b67ffffffffffffffff811660408401525087606083015260e060808301526145c260e08301878961423f565b6001600160a01b03861660a084015282810360c08401526145e481858761423f565b9a9950505050505050505050565b60006020828403121561460457600080fd5b815167ffffffffffffffff81111561461b57600080fd5b8201601f8101841361462c57600080fd5b805161463a613def82613d7f565b81815285602083850101111561464f57600080fd5b612a6f82602083016020860161392b565b60006040828403121561467257600080fd5b61467a613d25565b82358152602083013560208201528091505092915050565b600082516146a481846020870161392b565b7f2e4a504700000000000000000000000000000000000000000000000000000000920191825250600401919050565b7f7b226e616d65223a20224f4d4e4934303420230000000000000000000000000081526000825161470b81601385016020870161392b565b9190910160130192915050565b6000825161472a81846020870161392b565b7f222c226465736372697074696f6e223a225468652066726f6e74696572206f669201918252507f207065726d697373696f6e6c657373206173736574732e222c2265787465726e60208201527f616c5f75726c223a2268747470733a2f2f747769747465722e636f6d2f6f6d6e60408201527f69636861696e343034222c22696d616765223a220000000000000000000000006060820152607401919050565b60008084546147d9816140a8565b600182811680156147f1576001811461480657614835565b60ff1984168752821515830287019450614835565b8860005260208060002060005b8581101561482c5781548a820152908401908201614813565b50505082870194505b50505050835161484981836020880161392b565b01949350505050565b6000835161486481846020880161392b565b83519083019061484981836020880161392b565b7f646174613a6170706c69636174696f6e2f6a736f6e3b757466382c00000000008152600082516148b081601b85016020870161392b565b91909101601b0192915050565b6000602082840312156148cf57600080fd5b813561124481614555565b6001600160a01b038516815283602082015261ffff83166040820152608060608201526000611306608083018461394f565b80820180821115610e8a57610e8a6140dc565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b60008261495a5761495a614935565b500490565b604081526000614972604083018561394f565b8281036020840152612a6f818561394f565b60006020828403121561499657600080fd5b815161124481613c25565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a060808401526149d760e084018261394f565b90506060850151603f198483030160a08501526149f4828261394f565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b600060408284031215614a2c57600080fd5b614a34613d25565b9050815181526020820151602082015292915050565b600060408284031215614a5c57600080fd5b6112448383614a1a565b7fffff0000000000000000000000000000000000000000000000000000000000008135818116916002851015614aa65780818660020360031b1b83161692505b505092915050565b600060808284031215614ac057600080fd5b6040516060810181811067ffffffffffffffff82111715614ae357614ae3613d0f565b604052825181526020830151614af881614555565b6020820152614b0a8460408501614a1a565b60408201529392505050565b600060018201614b2857614b286140dc565b5060010190565b600082614b3e57614b3e614935565b500690565b8082028115828204841417610e8a57610e8a6140dc565b80356020831015610e8a57600019602084900360031b1b1692915050565b6001600160c01b03198135818116916008851015614aa65760089490940360031b84901b1690921692915050565b6001600160c01b03198560c01b1681526001600160e01b03198460e01b16600882015282600c82015260008251614be481602c85016020870161392b565b91909101602c0195945050505050565b8481526001600160c01b03198460c01b16602082015282602882015260008251614c2581604885016020870161392b565b9190910160480195945050505050565b600060208284031215614c4757600080fd5b8151611244816138f9565b600082516142c781846020870161392b56fea2646970667358221220f23390fbd88b0dcbac55d5cc43189c9d97dab47d20d3e4fedc5b356fb01103f664736f6c63430008170033ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef0000000000000000000000000000000000000000000000006124fee993bc00000000000000000000000000001a44076050125825900e736c501f859c50fe728c000000000000000000000000adf4c6b6909e5d6919311462bfb8d7835c8f6176
Deployed Bytecode
0x60806040526004361061038c5760003560e01c8063715018a6116101dc578063b92d0eff11610102578063ca5eb5e1116100a0578063e985e9c51161006f578063e985e9c514610b8a578063f2fde38b14610bc5578063fc0c546a146106b0578063ff7bd03d14610be557600080fd5b8063ca5eb5e114610aff578063d045a0dc14610b1f578063d424388514610b32578063dd62ed3e14610b5257600080fd5b8063bc70b354116100dc578063bc70b35414610a8b578063bd815db014610aab578063c7c7f5b314610abe578063c87b56dd14610adf57600080fd5b8063b92d0eff146106b0578063b98bd07014610a3e578063bb0b6a5314610a5e57600080fd5b8063976a84351161017a578063a9059cbb11610149578063a9059cbb146109a8578063b3f9ea34146109c8578063b731ea0a146109fe578063b88d4fde14610a1e57600080fd5b8063976a8435146109105780639b19251a146109445780639f68b96414610974578063a22cb4651461098857600080fd5b80638da5cb5b116101b65780638da5cb5b14610875578063922c36c31461089357806395d89b41146108c7578063963efcaa146108dc57600080fd5b8063715018a6146108105780637d25a05e14610825578063857749b01461086157600080fd5b80633400288b116102c15780635535d4611161025f5780636352211e1161022e5780636352211e1461078e5780636c0360eb146107ae5780636fc1b31e146107c357806370a08231146107e357600080fd5b80635535d461146106e357806355f804b3146107035780635a0dfe4d146107235780635e280f111461075a57600080fd5b80634b63babb1161029b5780634b63babb146106665780634f02c4201461069a57806352ae2879146106b057806353d6fd59146106c357600080fd5b80633400288b146105f95780633b6f743b1461061957806342842e0e1461064657600080fd5b8063134d4f251161032e57806318160ddd1161030857806318160ddd146105685780631f5e13341461057e57806323b872dd14610593578063313ce567146105b357600080fd5b8063134d4f25146104de578063156a0d0f1461050657806317442b701461054757600080fd5b8063095ea7b31161036a578063095ea7b31461044a5780630d35b4151461047a578063111ecdad146104a957806313137d65146104c957600080fd5b806302519da31461039157806306fdde03146103da578063081812fc146103fc575b600080fd5b34801561039d57600080fd5b506103c76103ac36600461390e565b6001600160a01b03166000908152600b602052604090205490565b6040519081526020015b60405180910390f35b3480156103e657600080fd5b506103ef610c05565b6040516103d1919061397b565b34801561040857600080fd5b5061043261041736600461398e565b600d602052600090815260409020546001600160a01b031681565b6040516001600160a01b0390911681526020016103d1565b34801561045657600080fd5b5061046a6104653660046139a7565b610c93565b60405190151581526020016103d1565b34801561048657600080fd5b5061049a6104953660046139eb565b610e90565b6040516103d193929190613a20565b3480156104b557600080fd5b50600454610432906001600160a01b031681565b6104dc6104d7366004613b14565b610f62565b005b3480156104ea57600080fd5b506104f3600281565b60405161ffff90911681526020016103d1565b34801561051257600080fd5b50604080517f02e49c2c00000000000000000000000000000000000000000000000000000000815260016020820152016103d1565b34801561055357600080fd5b506040805160018082526020820152016103d1565b34801561057457600080fd5b506103c760095481565b34801561058a57600080fd5b506104f3600181565b34801561059f57600080fd5b5061046a6105ae366004613bb4565b611054565b3480156105bf57600080fd5b506105e77f000000000000000000000000000000000000000000000000000000000000001281565b60405160ff90911681526020016103d1565b34801561060557600080fd5b506104dc610614366004613c09565b61124b565b34801561062557600080fd5b50610639610634366004613c33565b6112a9565b6040516103d19190613c85565b34801561065257600080fd5b506104dc610661366004613bb4565b611310565b34801561067257600080fd5b506103c77f000000000000000000000000000000000000000000000002b5e3af16b188000081565b3480156106a657600080fd5b506103c7600a5481565b3480156106bc57600080fd5b5030610432565b3480156106cf57600080fd5b506104dc6106de366004613c9c565b6113eb565b3480156106ef57600080fd5b506103ef6106fe366004613cdc565b611401565b34801561070f57600080fd5b506104dc61071e366004613da7565b611425565b34801561072f57600080fd5b5061046a61073e366004613c09565b63ffffffff919091166000908152600160205260409020541490565b34801561076657600080fd5b506104327f0000000000000000000000001a44076050125825900e736c501f859c50fe728c81565b34801561079a57600080fd5b506104326107a936600461398e565b611439565b3480156107ba57600080fd5b506103ef6114cb565b3480156107cf57600080fd5b506104dc6107de36600461390e565b6114d8565b3480156107ef57600080fd5b506103c76107fe36600461390e565b600b6020526000908152604090205481565b34801561081c57600080fd5b506104dc611535565b34801561083157600080fd5b50610848610840366004613c09565b600092915050565b60405167ffffffffffffffff90911681526020016103d1565b34801561086d57600080fd5b5060066105e7565b34801561088157600080fd5b506000546001600160a01b0316610432565b34801561089f57600080fd5b506103c77f000000000000000000000000000000000000000000000000000000000000003281565b3480156108d357600080fd5b506103ef611549565b3480156108e857600080fd5b506103c77f000000000000000000000000000000000000000000000000000000e8d4a5100081565b34801561091c57600080fd5b506103c77f0000000000000000000000000000000000000000000000000de0b6b3a764000081565b34801561095057600080fd5b5061046a61095f36600461390e565b60126020526000908152604090205460ff1681565b34801561098057600080fd5b50600061046a565b34801561099457600080fd5b506104dc6109a3366004613c9c565b611556565b3480156109b457600080fd5b5061046a6109c33660046139a7565b611602565b3480156109d457600080fd5b506103c76109e336600461390e565b6001600160a01b031660009081526010602052604090205490565b348015610a0a57600080fd5b50600254610432906001600160a01b031681565b348015610a2a57600080fd5b506104dc610a39366004613e27565b6116dd565b348015610a4a57600080fd5b506104dc610a59366004613edf565b6117a8565b348015610a6a57600080fd5b506103c7610a79366004613f21565b60016020526000908152604090205481565b348015610a9757600080fd5b506103ef610aa6366004613f3c565b611909565b6104dc610ab9366004613edf565b611a84565b610ad1610acc366004613f9d565b611c27565b6040516103d192919061400b565b348015610aeb57600080fd5b506103ef610afa36600461398e565b611d21565b348015610b0b57600080fd5b506104dc610b1a36600461390e565b611e58565b6104dc610b2d366004613b14565b611ef0565b348015610b3e57600080fd5b506104dc610b4d36600461390e565b611f38565b348015610b5e57600080fd5b506103c7610b6d36600461405e565b600c60209081526000928352604080842090915290825290205481565b348015610b9657600080fd5b5061046a610ba536600461405e565b600e60209081526000928352604080842090915290825290205460ff1681565b348015610bd157600080fd5b506104dc610be036600461390e565b611f8e565b348015610bf157600080fd5b5061046a610c0036600461408c565b61201e565b60078054610c12906140a8565b80601f0160208091040260200160405190810160405280929190818152602001828054610c3e906140a8565b8015610c8b5780601f10610c6057610100808354040283529160200191610c8b565b820191906000526020600020905b815481529060010190602001808311610c6e57829003601f168201915b505050505081565b60007f00000000000000000000000000000000000000000000000000000000000000328211158015610cc55750600082115b15610de0576000828152600f602052604090205482906001600160a01b0316338114801590610d1857506001600160a01b0381166000908152600e6020908152604080832033845290915290205460ff16155b15610d35576040516282b42960e81b815260040160405180910390fd5b6000828152600d602090815260409182902080546001600160a01b0319166001600160a01b038981169182179092559251858152908416917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a381856001600160a01b0316826001600160a01b03167f797365dabb18fa726ccbccbe18c6f24c34e3b0653f2e99ea873bd7b84763dde660405160405180910390a45050610e86565b336000818152600c602090815260408083206001600160a01b03881680855290835292819020869055518581528593917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3604080513381526001600160a01b03861660208201529081018290527f1f01303a1ce9329d9963e1937c201e23c5543a9e3536e9edead087aec7dc6d839060600160405180910390a1505b5060015b92915050565b60408051808201909152600080825260208201526060610ec3604051806040016040528060008152602001600081525090565b604080518082018252600080825267ffffffffffffffff602080840182905284518381529081019094529195509182610f1f565b604080518082019091526000815260606020820152815260200190600190039081610ef75790505b509350600080610f44604089013560608a0135610f3f60208c018c613f21565b612054565b60408051808201909152918252602082015296989597505050505050565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b03163314610fcb576040517f91ac5e4f0000000000000000000000000000000000000000000000000000000081523360048201526024015b60405180910390fd5b60208701803590610fe590610fe0908a613f21565b6120b1565b1461103c57610ff76020880188613f21565b6040517fc26bebcc00000000000000000000000000000000000000000000000000000000815263ffffffff909116600482015260208801356024820152604401610fc2565b61104b87878787878787612106565b50505050505050565b60006001600160a01b03831661107d57604051634e46966960e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000328211611199576000828152600f602052604090205482906001600160a01b038681169116146110e057604051636edaef2f60e11b815260040160405180910390fd5b336001600160a01b0386161480159061111d57506001600160a01b0385166000908152600e6020908152604080832033845290915290205460ff16155b801561114057506000818152600d60205260409020546001600160a01b03163314155b1561115d576040516282b42960e81b815260040160405180910390fd5b61118885857f0000000000000000000000000000000000000000000000000de0b6b3a7640000612286565b611193858583612460565b50611240565b6001600160a01b0384166000908152600c60209081526040808320338452909152902054829060001981146112315781811015611202576040517f13be252b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61120c82826140f2565b6001600160a01b0387166000908152600c602090815260408083203384529091529020555b61123c86868461264f565b5050505b5060015b9392505050565b611253612800565b63ffffffff8216600081815260016020908152604091829020849055815192835282018390527f238399d427b947898edb290f5ff0f9109849b1c3ba196a42e35f00c50a54b98b91015b60405180910390a15050565b604080518082019091526000808252602082015260006112d960408501356060860135610f3f6020880188613f21565b9150506000806112e9868461285a565b90925090506113066112fe6020880188613f21565b838388612997565b9695505050505050565b61131b838383611054565b506001600160a01b0382163b158015906113c85750604051630a85bd0160e11b8082523360048301526001600160a01b03858116602484015260448301849052608060648401526000608484015290919084169063150b7a029060a4016020604051808303816000875af1158015611397573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bb9190614105565b6001600160e01b03191614155b156113e657604051633da6393160e01b815260040160405180910390fd5b505050565b6113f3612800565b6113fd8282612a78565b5050565b600360209081526000928352604080842090915290825290208054610c12906140a8565b61142d612800565b60136113fd828261417f565b6000818152600f60205260409020546001600160a01b03167f000000000000000000000000000000000000000000000000000000000000003282118061147d575081155b8061148f57506001600160a01b038116155b156114c6576040517fc5723b5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b919050565b60138054610c12906140a8565b6114e0612800565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527ff0be4f1e87349231d80c36b33f9e8639658eeaf474014dee15a3e6a4d4414197906020015b60405180910390a150565b61153d612800565b6115476000612b26565b565b60088054610c12906140a8565b6001600160a01b038216611596576040517fccea9e6f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336000818152600e602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006001600160a01b03831661162b57604051634e46966960e11b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000003282116116c6576000828152600f602052604090205482906001600160a01b0316331461168a576040516282b42960e81b815260040160405180910390fd5b6116b533857f0000000000000000000000000000000000000000000000000de0b6b3a7640000612286565b6116c0338583612460565b50610e86565b816116d233858361264f565b505050600192915050565b6116e8858585611054565b506001600160a01b0384163b158015906117835750604051630a85bd0160e11b808252906001600160a01b0386169063150b7a02906117339033908a90899089908990600401614268565b6020604051808303816000875af1158015611752573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117769190614105565b6001600160e01b03191614155b156117a157604051633da6393160e01b815260040160405180910390fd5b5050505050565b6117b0612800565b60005b818110156118d7576117f58383838181106117d0576117d061429b565b90506020028101906117e291906142b1565b6117f09060408101906142d1565b612b76565b8282828181106118075761180761429b565b905060200281019061181991906142b1565b6118279060408101906142d1565b6003600086868681811061183d5761183d61429b565b905060200281019061184f91906142b1565b61185d906020810190613f21565b63ffffffff1663ffffffff168152602001908152602001600020600086868681811061188b5761188b61429b565b905060200281019061189d91906142b1565b6118ae906040810190602001614318565b61ffff1681526020810191909152604001600020916118ce919083614333565b506001016117b3565b507fbe4864a8e820971c0247f5992e2da559595f7bf076a21cb5928d443d2a13b674828260405161129d9291906143f3565b63ffffffff8416600090815260036020908152604080832061ffff8716845290915281208054606092919061193d906140a8565b80601f0160208091040260200160405190810160405280929190818152602001828054611969906140a8565b80156119b65780601f1061198b576101008083540402835291602001916119b6565b820191906000526020600020905b81548152906001019060200180831161199957829003601f168201915b505050505090508051600003611a065783838080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929450611a7c9350505050565b6000839003611a16579050611a7c565b60028310611a5f57611a288484612b76565b80611a3684600281886144d8565b604051602001611a4893929190614502565b604051602081830303815290604052915050611a7c565b8383604051639a6d49cd60e01b8152600401610fc292919061452a565b949350505050565b60005b81811015611b8d5736838383818110611aa257611aa261429b565b9050602002810190611ab4919061453e565b9050611ae7611ac66020830183613f21565b602083013563ffffffff919091166000908152600160205260409020541490565b611af15750611b85565b3063d045a0dc60c08301358360a0810135611b106101008301836142d1565b611b21610100890160e08a0161390e565b611b2f6101208a018a6142d1565b6040518963ffffffff1660e01b8152600401611b51979695949392919061456b565b6000604051808303818588803b158015611b6a57600080fd5b505af1158015611b7e573d6000803e3d6000fd5b5050505050505b600101611a87565b50336001600160a01b0316638e9e70996040518163ffffffff1660e01b8152600401600060405180830381865afa158015611bcc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611bf491908101906145f2565b6040517f8351eea7000000000000000000000000000000000000000000000000000000008152600401610fc2919061397b565b611c2f6138b1565b6040805180820190915260008082526020820152600080611c6560408801356060890135611c6060208b018b613f21565b612bb8565b91509150600080611c76898461285a565b9092509050611ca2611c8b60208b018b613f21565b8383611c9c368d90038d018d614660565b8b612bd5565b60408051808201909152858152602080820186905282519298509096503391907f85496b760a4b7f8d66384b9df21b381f5d1b1e79f229a47aaf4c232edc2fe59a90611cf0908d018d613f21565b6040805163ffffffff909216825260208201899052810187905260600160405180910390a350505050935093915050565b60606000611d2e83612ce0565b604051602001611d3e9190614692565b60405160208183030381529060405290506000611d5a84612ce0565b604051602001611d6a91906146d3565b60408051601f1981840301815290829052611d8791602001614718565b604051602081830303815290604052601383604051602001611daa9291906147cb565b60408051601f1981840301815290829052611dc89291602001614852565b60408051808303601f190181528282527f227d00000000000000000000000000000000000000000000000000000000000060208401528151600281850301815260228401909252925090611e229083908390604201614852565b60408051601f1981840301815290829052611e3f91602001614878565b6040516020818303038152906040529350505050919050565b611e60612800565b6040517fca5eb5e10000000000000000000000000000000000000000000000000000000081526001600160a01b0382811660048301527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c169063ca5eb5e190602401600060405180830381600087803b158015611edc57600080fd5b505af11580156117a1573d6000803e3d6000fd5b333014611f29576040517f14d4a4e800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61104b8787878787878761103c565b611f40612800565b600280546001600160a01b0319166001600160a01b0383169081179091556040519081527fd48d879cef83a1c0bdda516f27b13ddb1b3f8bbac1c9e1511bb2a659c24277609060200161152a565b611f96612800565b6001600160a01b0381166120125760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610fc2565b61201b81612b26565b50565b60006020820180359060019083906120369086613f21565b63ffffffff1681526020810191909152604001600020541492915050565b60008061206085612e15565b9150819050838110156120a9576040517f71c4efed0000000000000000000000000000000000000000000000000000000081526004810182905260248101859052604401610fc2565b935093915050565b63ffffffff811660009081526001602052604081205480610e8a576040517ff6ff4fb700000000000000000000000000000000000000000000000000000000815263ffffffff84166004820152602401610fc2565b60006121186121158787612e4c565b90565b905060006121448261213261212d8a8a612e64565b612e87565b61213f60208d018d613f21565b612ebd565b9050602886111561222457600061218161216460608c0160408d016148bd565b61217160208d018d613f21565b8461217c8c8c612ed1565b612f1c565b6040517f7cb590120000000000000000000000000000000000000000000000000000000081529091506001600160a01b037f0000000000000000000000001a44076050125825900e736c501f859c50fe728c1690637cb59012906121f09086908d9060009087906004016148da565b600060405180830381600087803b15801561220a57600080fd5b505af115801561221e573d6000803e3d6000fd5b50505050505b6001600160a01b038216887fefed6d3500546b29533b128a29e3a94d70788727f0507505ac12eaf2e578fd9c61225d60208d018d613f21565b6040805163ffffffff9092168252602082018690520160405180910390a3505050505050505050565b6001600160a01b038316612308577f000000000000000000000000000000000000000000000002b5e3af16b1880000816009546122c3919061490c565b11156122fb576040517f029ab20200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600980548201905561239f565b6001600160a01b0383166000908152600b602052604090205481111561235a576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0383166000908152600b6020526040812080548392906123829084906140f2565b90915550506001600160a01b03821661239f576009805482900390555b6001600160a01b038216156123cd576001600160a01b0382166000908152600b602052604090208054820190555b80826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4816001600160a01b0316836001600160a01b03167fe59fdd36d0d223c0c7d996db7ad796880f45e1936cb0bb7ac102e7082e0314878360405161245391815260200190565b60405180910390a3505050565b6001600160a01b03831615612567576000818152600d6020908152604080832080546001600160a01b03191690556001600160a01b03861683526010909152812080546124af906001906140f2565b815481106124bf576124bf61429b565b60009182526020808320909101546001600160a01b03871683526010825260408084208685526011909352909220548154929350839281106125035761250361429b565b60009182526020808320909101929092556001600160a01b03861681526010909152604090208054806125385761253861491f565b600082815260208082208301600019908101839055909201909255838252601190526040808220549282529020555b6000818152600f6020908152604080832080546001600160a01b0319166001600160a01b0387169081179091558084526010835290832080546001818101835582865293852001859055925290546125bf91906140f2565b60008281526011602052604080822092909255905182916001600160a01b0380861692908716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a480826001600160a01b0316846001600160a01b03167fe5f815dc84b8cecdfd4beedfc3f91ab5be7af100eca4e8fb11552b867995394f60405160405180910390a4505050565b6001600160a01b038381166000908152600b6020526040808220549285168252812054909190612680868686612286565b6001600160a01b03861660009081526012602052604090205460ff16612739576001600160a01b0386166000908152600b60205260408120546126e4907f0000000000000000000000000000000000000000000000000de0b6b3a76400009061494b565b61270e7f0000000000000000000000000000000000000000000000000de0b6b3a76400008561494b565b61271891906140f2565b905060005b818110156127365761272e88612f4e565b60010161271d565b50505b6001600160a01b03851660009081526012602052604090205460ff166127f45760006127857f0000000000000000000000000000000000000000000000000de0b6b3a76400008361494b565b6001600160a01b0387166000908152600b60205260409020546127c9907f0000000000000000000000000000000000000000000000000de0b6b3a76400009061494b565b6127d391906140f2565b905060005b818110156127f1576127e987612fe3565b6001016127d8565b50505b50600195945050505050565b6000546001600160a01b031633146115475760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fc2565b60608060006128b7856020013561287086613143565b61287d60a08901896142d1565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061316f92505050565b90935090506000816128ca5760016128cd565b60025b90506128ed6128df6020880188613f21565b82610aa660808a018a6142d1565b6004549093506001600160a01b03161561298e57600480546040517f043a78eb0000000000000000000000000000000000000000000000000000000081526001600160a01b039091169163043a78eb9161294b91889188910161495f565b602060405180830381865afa158015612968573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061298c9190614984565b505b50509250929050565b60408051808201909152600080825260208201527f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663ddc28c586040518060a001604052808863ffffffff1681526020016129fa896120b1565b8152602001878152602001868152602001851515815250306040518363ffffffff1660e01b8152600401612a2f9291906149a1565b6040805180830381865afa158015612a4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a6f9190614a4a565b95945050505050565b7f0000000000000000000000000000000000000000000000000de0b6b3a7640000612ab8836001600160a01b03166000908152600b602052604090205490565b10158015612ac4575080155b15612afb576040517f787b1a4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03919091166000908152601260205260409020805460ff1916911515919091179055565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000612b8560028284866144d8565b612b8e91614a66565b60f01c9050600381146113e6578282604051639a6d49cd60e01b8152600401610fc292919061452a565b600080612bc6858585612054565b90925090506120a933836131e9565b612bdd6138b1565b6000612bec84600001516132ed565b602085015190915015612c0657612c06846020015161332e565b7f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b0316632637a450826040518060a001604052808b63ffffffff168152602001612c568c6120b1565b81526020018a815260200189815260200160008960200151111515815250866040518463ffffffff1660e01b8152600401612c929291906149a1565b60806040518083038185885af1158015612cb0573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190612cd59190614aae565b979650505050505050565b606081600003612d2357505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612d4d5780612d3781614b16565b9150612d469050600a8361494b565b9150612d27565b60008167ffffffffffffffff811115612d6857612d68613d0f565b6040519080825280601f01601f191660200182016040528015612d92576020820181803683370190505b5090505b8415611a7c57612da76001836140f2565b9150612db4600a86614b2f565b612dbf90603061490c565b60f81b818381518110612dd457612dd461429b565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612e0e600a8661494b565b9450612d96565b60007f000000000000000000000000000000000000000000000000000000e8d4a51000612e42818461494b565b610e8a9190614b43565b6000612e5b60208284866144d8565b61124491614b5a565b6000612e746028602084866144d8565b612e7d91614b78565b60c01c9392505050565b6000610e8a7f000000000000000000000000000000000000000000000000000000e8d4a5100067ffffffffffffffff8416614b43565b6000612ec98484613429565b509092915050565b6060612ee082602881866144d8565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929695505050505050565b606084848484604051602001612f359493929190614ba6565b6040516020818303038152906040529050949350505050565b6001600160a01b0381161580612f6c57506001600160a01b03811630145b15612f8a57604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b03811660009081526010602052604081208054612fb0906001906140f2565b81548110612fc057612fc061429b565b90600052602060002001549050612fd8823083612460565b6113fd60058261352d565b6001600160a01b038116158061300157506001600160a01b03811630145b1561301f57604051634e46966960e11b815260040160405180910390fd5b6000613048600554600160801b81046fffffffffffffffffffffffffffffffff90811691161490565b61305d5761305660056135b2565b90506130d1565b600a805490600061306d83614b16565b9091555050600a5490507f00000000000000000000000000000000000000000000000000000000000000328111156130d1576040517f77a4ae0900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000818152600f60205260409020546001600160a01b0316801580159061310157506001600160a01b0381163014155b15613138576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113e6818484612460565b6000610e8a7f000000000000000000000000000000000000000000000000000000e8d4a510008361494b565b80516060901515806131b85784846040516020016131a492919091825260c01b6001600160c01b031916602082015260280190565b6040516020818303038152906040526131df565b848433856040516020016131cf9493929190614bf4565b6040516020818303038152906040525b9150935093915050565b6001600160a01b03821661321057604051636edaef2f60e11b815260040160405180910390fd5b6001600160a01b0382166000908152600b6020526040812054905061323783600084612286565b6001600160a01b03831660009081526012602052604090205460ff166113e6576001600160a01b0383166000908152600b602052604081205461329b907f0000000000000000000000000000000000000000000000000de0b6b3a76400009061494b565b6132c57f0000000000000000000000000000000000000000000000000de0b6b3a76400008461494b565b6132cf91906140f2565b905060005b818110156117a1576132e585612f4e565b6001016132d4565b600081341461332a576040517f9f704120000000000000000000000000000000000000000000000000000000008152346004820152602401610fc2565b5090565b60007f0000000000000000000000001a44076050125825900e736c501f859c50fe728c6001600160a01b031663e4fe1d946040518163ffffffff1660e01b8152600401602060405180830381865afa15801561338e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133b29190614c35565b90506001600160a01b0381166133f4576040517f5373352a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6113fd6001600160a01b038216337f0000000000000000000000001a44076050125825900e736c501f859c50fe728c85613625565b6001600160a01b03821661345057604051634e46966960e11b815260040160405180910390fd5b6001600160a01b0382166000908152600b602052604081205490613475908484612286565b6001600160a01b03831660009081526012602052604090205460ff166113e65760006134c17f0000000000000000000000000000000000000000000000000de0b6b3a76400008361494b565b6001600160a01b0385166000908152600b6020526040902054613505907f0000000000000000000000000000000000000000000000000de0b6b3a76400009061494b565b61350f91906140f2565b905060005b818110156117a15761352585612fe3565b600101613514565b81546fffffffffffffffffffffffffffffffff8082166000190191600160801b90048116908216036135635761356360416136b3565b6fffffffffffffffffffffffffffffffff16600081815260018401602052604090209190915581547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016179055565b80546000906fffffffffffffffffffffffffffffffff600160801b82048116911681036135e3576135e360316136b3565b600019016fffffffffffffffffffffffffffffffff9081166000818152600185016020526040812080549190558454909216600160801b909102179092555090565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd000000000000000000000000000000000000000000000000000000001790526136ad9085906136c8565b50505050565b634e487b7160e01b6000528060045260246000fd5b600061371d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166137ad9092919063ffffffff16565b8051909150156113e6578080602001905181019061373b9190614984565b6113e65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610fc2565b6060611a7c8484600085856001600160a01b0385163b61380f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc2565b600080866001600160a01b0316858760405161382b9190614c52565b60006040518083038185875af1925050503d8060008114613868576040519150601f19603f3d011682016040523d82523d6000602084013e61386d565b606091505b5091509150612cd582828660608315613887575081611244565b8251156138975782518084602001fd5b8160405162461bcd60e51b8152600401610fc2919061397b565b604051806060016040528060008019168152602001600067ffffffffffffffff1681526020016138f4604051806040016040528060008152602001600081525090565b905290565b6001600160a01b038116811461201b57600080fd5b60006020828403121561392057600080fd5b8135611244816138f9565b60005b8381101561394657818101518382015260200161392e565b50506000910152565b6000815180845261396781602086016020860161392b565b601f01601f19169290920160200192915050565b602081526000611244602083018461394f565b6000602082840312156139a057600080fd5b5035919050565b600080604083850312156139ba57600080fd5b82356139c5816138f9565b946020939093013593505050565b600060e082840312156139e557600080fd5b50919050565b6000602082840312156139fd57600080fd5b813567ffffffffffffffff811115613a1457600080fd5b611a7c848285016139d3565b8351815260208085015190820152600060a08201604060a0604085015281865180845260c08601915060c08160051b8701019350602080890160005b83811015613a9b5788870360bf19018552815180518852830151838801879052613a888789018261394f565b9750509382019390820190600101613a5c565b50508751606088015250505060208501516080850152509050611a7c565b6000606082840312156139e557600080fd5b60008083601f840112613add57600080fd5b50813567ffffffffffffffff811115613af557600080fd5b602083019150836020828501011115613b0d57600080fd5b9250929050565b600080600080600080600060e0888a031215613b2f57600080fd5b613b398989613ab9565b965060608801359550608088013567ffffffffffffffff80821115613b5d57600080fd5b613b698b838c01613acb565b909750955060a08a01359150613b7e826138f9565b90935060c08901359080821115613b9457600080fd5b50613ba18a828b01613acb565b989b979a50959850939692959293505050565b600080600060608486031215613bc957600080fd5b8335613bd4816138f9565b92506020840135613be4816138f9565b929592945050506040919091013590565b803563ffffffff811681146114c657600080fd5b60008060408385031215613c1c57600080fd5b6139c583613bf5565b801515811461201b57600080fd5b60008060408385031215613c4657600080fd5b823567ffffffffffffffff811115613c5d57600080fd5b613c69858286016139d3565b9250506020830135613c7a81613c25565b809150509250929050565b815181526020808301519082015260408101610e8a565b60008060408385031215613caf57600080fd5b8235613cba816138f9565b91506020830135613c7a81613c25565b803561ffff811681146114c657600080fd5b60008060408385031215613cef57600080fd5b613cf883613bf5565b9150613d0660208401613cca565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715613d4857613d48613d0f565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613d7757613d77613d0f565b604052919050565b600067ffffffffffffffff821115613d9957613d99613d0f565b50601f01601f191660200190565b600060208284031215613db957600080fd5b813567ffffffffffffffff811115613dd057600080fd5b8201601f81018413613de157600080fd5b8035613df4613def82613d7f565b613d4e565b818152856020838501011115613e0957600080fd5b81602084016020830137600091810160200191909152949350505050565b600080600080600060808688031215613e3f57600080fd5b8535613e4a816138f9565b94506020860135613e5a816138f9565b935060408601359250606086013567ffffffffffffffff811115613e7d57600080fd5b613e8988828901613acb565b969995985093965092949392505050565b60008083601f840112613eac57600080fd5b50813567ffffffffffffffff811115613ec457600080fd5b6020830191508360208260051b8501011115613b0d57600080fd5b60008060208385031215613ef257600080fd5b823567ffffffffffffffff811115613f0957600080fd5b613f1585828601613e9a565b90969095509350505050565b600060208284031215613f3357600080fd5b61124482613bf5565b60008060008060608587031215613f5257600080fd5b613f5b85613bf5565b9350613f6960208601613cca565b9250604085013567ffffffffffffffff811115613f8557600080fd5b613f9187828801613acb565b95989497509550505050565b60008060008385036080811215613fb357600080fd5b843567ffffffffffffffff811115613fca57600080fd5b613fd6878288016139d3565b9450506040601f1982011215613feb57600080fd5b506020840191506060840135614000816138f9565b809150509250925092565b600060c0820190508351825267ffffffffffffffff60208501511660208301526040840151614047604084018280518252602090810151910152565b5082516080830152602083015160a0830152611244565b6000806040838503121561407157600080fd5b823561407c816138f9565b91506020830135613c7a816138f9565b60006060828403121561409e57600080fd5b6112448383613ab9565b600181811c908216806140bc57607f821691505b6020821081036139e557634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610e8a57610e8a6140dc565b60006020828403121561411757600080fd5b81516001600160e01b03198116811461124457600080fd5b601f8211156113e6576000816000526020600020601f850160051c810160208610156141585750805b601f850160051c820191505b8181101561417757828155600101614164565b505050505050565b815167ffffffffffffffff81111561419957614199613d0f565b6141ad816141a784546140a8565b8461412f565b602080601f8311600181146141e257600084156141ca5750858301515b600019600386901b1c1916600185901b178555614177565b600085815260208120601f198616915b82811015614211578886015182559484019460019091019084016141f2565b508582101561422f5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b03808816835280871660208401525084604083015260806060830152612cd560808301848661423f565b634e487b7160e01b600052603260045260246000fd5b60008235605e198336030181126142c757600080fd5b9190910192915050565b6000808335601e198436030181126142e857600080fd5b83018035915067ffffffffffffffff82111561430357600080fd5b602001915036819003821315613b0d57600080fd5b60006020828403121561432a57600080fd5b61124482613cca565b67ffffffffffffffff83111561434b5761434b613d0f565b61435f8361435983546140a8565b8361412f565b6000601f841160018114614393576000851561437b5750838201355b600019600387901b1c1916600186901b1783556117a1565b600083815260209020601f19861690835b828110156143c457868501358255602094850194600190920191016143a4565b50868210156143e15760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b60208082528181018390526000906040808401600586901b8501820187855b888110156144ca57878303603f190184528135368b9003605e1901811261443857600080fd5b8a01606063ffffffff61444a83613bf5565b16855261ffff61445b898401613cca565b168886015286820135601e1983360301811261447657600080fd5b90910187810191903567ffffffffffffffff81111561449457600080fd5b8036038313156144a357600080fd5b81888701526144b5828701828561423f565b96890196955050509186019150600101614412565b509098975050505050505050565b600080858511156144e857600080fd5b838611156144f557600080fd5b5050820193919092039150565b6000845161451481846020890161392b565b8201838582376000930192835250909392505050565b602081526000611a7c60208301848661423f565b6000823561013e198336030181126142c757600080fd5b67ffffffffffffffff8116811461201b57600080fd5b63ffffffff61457989613bf5565b168152602088013560208201526000604089013561459681614555565b67ffffffffffffffff811660408401525087606083015260e060808301526145c260e08301878961423f565b6001600160a01b03861660a084015282810360c08401526145e481858761423f565b9a9950505050505050505050565b60006020828403121561460457600080fd5b815167ffffffffffffffff81111561461b57600080fd5b8201601f8101841361462c57600080fd5b805161463a613def82613d7f565b81815285602083850101111561464f57600080fd5b612a6f82602083016020860161392b565b60006040828403121561467257600080fd5b61467a613d25565b82358152602083013560208201528091505092915050565b600082516146a481846020870161392b565b7f2e4a504700000000000000000000000000000000000000000000000000000000920191825250600401919050565b7f7b226e616d65223a20224f4d4e4934303420230000000000000000000000000081526000825161470b81601385016020870161392b565b9190910160130192915050565b6000825161472a81846020870161392b565b7f222c226465736372697074696f6e223a225468652066726f6e74696572206f669201918252507f207065726d697373696f6e6c657373206173736574732e222c2265787465726e60208201527f616c5f75726c223a2268747470733a2f2f747769747465722e636f6d2f6f6d6e60408201527f69636861696e343034222c22696d616765223a220000000000000000000000006060820152607401919050565b60008084546147d9816140a8565b600182811680156147f1576001811461480657614835565b60ff1984168752821515830287019450614835565b8860005260208060002060005b8581101561482c5781548a820152908401908201614813565b50505082870194505b50505050835161484981836020880161392b565b01949350505050565b6000835161486481846020880161392b565b83519083019061484981836020880161392b565b7f646174613a6170706c69636174696f6e2f6a736f6e3b757466382c00000000008152600082516148b081601b85016020870161392b565b91909101601b0192915050565b6000602082840312156148cf57600080fd5b813561124481614555565b6001600160a01b038516815283602082015261ffff83166040820152608060608201526000611306608083018461394f565b80820180821115610e8a57610e8a6140dc565b634e487b7160e01b600052603160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b60008261495a5761495a614935565b500490565b604081526000614972604083018561394f565b8281036020840152612a6f818561394f565b60006020828403121561499657600080fd5b815161124481613c25565b6040815263ffffffff8351166040820152602083015160608201526000604084015160a060808401526149d760e084018261394f565b90506060850151603f198483030160a08501526149f4828261394f565b60809690960151151560c08501525050506001600160a01b039190911660209091015290565b600060408284031215614a2c57600080fd5b614a34613d25565b9050815181526020820151602082015292915050565b600060408284031215614a5c57600080fd5b6112448383614a1a565b7fffff0000000000000000000000000000000000000000000000000000000000008135818116916002851015614aa65780818660020360031b1b83161692505b505092915050565b600060808284031215614ac057600080fd5b6040516060810181811067ffffffffffffffff82111715614ae357614ae3613d0f565b604052825181526020830151614af881614555565b6020820152614b0a8460408501614a1a565b60408201529392505050565b600060018201614b2857614b286140dc565b5060010190565b600082614b3e57614b3e614935565b500690565b8082028115828204841417610e8a57610e8a6140dc565b80356020831015610e8a57600019602084900360031b1b1692915050565b6001600160c01b03198135818116916008851015614aa65760089490940360031b84901b1690921692915050565b6001600160c01b03198560c01b1681526001600160e01b03198460e01b16600882015282600c82015260008251614be481602c85016020870161392b565b91909101602c0195945050505050565b8481526001600160c01b03198460c01b16602082015282602882015260008251614c2581604885016020870161392b565b9190910160480195945050505050565b600060208284031215614c4757600080fd5b8151611244816138f9565b600082516142c781846020870161392b56fea2646970667358221220f23390fbd88b0dcbac55d5cc43189c9d97dab47d20d3e4fedc5b356fb01103f664736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000006124fee993bc00000000000000000000000000001a44076050125825900e736c501f859c50fe728c000000000000000000000000adf4c6b6909e5d6919311462bfb8d7835c8f6176
-----Decoded View---------------
Arg [0] : _initialSupplyERC20 (uint256): 7000000000000000000
Arg [1] : _lzEndpoint (address): 0x1a44076050125825900e736c501f859c50fE728c
Arg [2] : _delegate (address): 0xADf4c6b6909E5D6919311462bFB8d7835C8f6176
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000006124fee993bc0000
Arg [1] : 0000000000000000000000001a44076050125825900e736c501f859c50fe728c
Arg [2] : 000000000000000000000000adf4c6b6909e5d6919311462bfb8d7835c8f6176
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$224.49
Net Worth in ETH
0.075946
Token Allocations
AVAX
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| AVAX | 100.00% | $12.01 | 18.6933 | $224.49 |
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.