ERC-20
DeFi
Overview
Max Total Supply
16,150,559.94229991 OOE
Holders
8,311 (0.00%)
Market
Price
$0.0076 @ 0.000002 ETH (+0.30%)
Onchain Market Cap
$122,607.14
Circulating Supply Market Cap
$3,822,440.00
Other Info
Token Contract (WITH 18 Decimals)
Balance
305.733772065151477355 OOEValue
$2.32 ( ~0.000703764613153837 ETH) [0.0019%]Loading...
Loading
Loading...
Loading
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x0838d98f...a6758383a The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
OFTV2
Compiler Version
v0.8.12+commit.f00d7308
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./BaseOFTV2.sol"; contract OFTV2 is BaseOFTV2, ERC20 { uint internal immutable ld2sdRate; constructor( string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint ) ERC20(_name, _symbol) BaseOFTV2(_sharedDecimals, _lzEndpoint) { uint8 decimals = decimals(); require(_sharedDecimals <= decimals, "OFT: sharedDecimals must be <= decimals"); ld2sdRate = 10**(decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function token() public view virtual override returns (address) { return address(this); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom( address _from, uint16, bytes32, uint _amount ) internal virtual override returns (uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo( uint16, address _toAddress, uint _amount ) internal virtual override returns (uint) { _mint(_toAddress, _amount); return _amount; } function _transferFrom( address _from, address _to, uint _amount ) internal virtual override returns (uint) { address spender = _msgSender(); // if transfer from this contract, no need to check allowance if (_from != address(this) && _from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, _to, _amount); return _amount; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../lzApp/NonblockingLzApp.sol"; /// @title GasDrop /// @notice A contract for sending and receiving gas across chains using LayerZero's NonblockingLzApp. contract GasDrop is NonblockingLzApp { /// @notice The version of the adapterParams. uint16 public constant VERSION = 2; /// @notice The default amount of gas to be used on the destination chain. uint public dstGas = 25000; /// @dev Emitted when the destination gas is updated. event SetDstGas(uint dstGas); /// @dev Emitted when a gas drop is sent. event SendGasDrop(uint16 indexed _dstChainId, address indexed _from, bytes indexed _toAddress, uint _amount); /// @dev Emitted when a gas drop is received on this chain. event ReceiveGasDrop(uint16 indexed _srcChainId, address indexed _from, bytes indexed _toAddress, uint _amount); /// @param _endpoint The LayerZero endpoint address. constructor(address _endpoint) NonblockingLzApp(_endpoint) {} /// @dev Internal function to handle incoming LayerZero messages and emit a ReceiveGasDrop event. /// @param _srcChainId The source chain ID from where the message originated. /// @param _payload The payload of the incoming message. function _nonblockingLzReceive(uint16 _srcChainId, bytes memory, uint64, bytes memory _payload) internal virtual override { (uint amount, address fromAddress, bytes memory toAddress) = abi.decode(_payload, (uint, address, bytes)); emit ReceiveGasDrop(_srcChainId, fromAddress, toAddress, amount); } /// @notice Estimate the fee for sending a gas drop to other chains. /// @param _dstChainId Array of destination chain IDs. /// @param _toAddress Array of destination addresses. /// @param _amount Array of amounts to send. /// @param _useZro Whether to use ZRO for payment or not. /// @return nativeFee The total native fee for all destinations. /// @return zroFee The total ZRO fee for all destinations. function estimateSendFee(uint16[] calldata _dstChainId, bytes[] calldata _toAddress, uint[] calldata _amount, bool _useZro) external view virtual returns (uint nativeFee, uint zroFee) { require(_dstChainId.length == _toAddress.length, "_dstChainId and _toAddress must be same size"); require(_toAddress.length == _amount.length, "_toAddress and _amount must be same size"); for(uint i = 0; i < _dstChainId.length; i++) { bytes memory adapterParams = abi.encodePacked(VERSION, dstGas, _amount[i], _toAddress[i]); bytes memory payload = abi.encode(_amount[i], msg.sender, _toAddress[i]); (uint native, uint zro) = lzEndpoint.estimateFees(_dstChainId[i], address(this), payload, _useZro, adapterParams); nativeFee += native; zroFee += zro; } } /// @notice Send gas drops to other chains. /// @param _dstChainId Array of destination chain IDs. /// @param _toAddress Array of destination addresses. /// @param _amount Array of amounts to send. /// @param _refundAddress Address for refunds. /// @param _zroPaymentAddress Address for ZRO payments. function gasDrop(uint16[] calldata _dstChainId, bytes[] calldata _toAddress, uint[] calldata _amount, address payable _refundAddress, address _zroPaymentAddress) external payable virtual { require(_dstChainId.length == _toAddress.length, "_dstChainId and _toAddress must be same size"); require(_toAddress.length == _amount.length, "_toAddress and _amount must be same size"); uint _dstGas = dstGas; for(uint i = 0; i < _dstChainId.length; i++) { bytes memory adapterParams = abi.encodePacked(VERSION, _dstGas, _amount[i], _toAddress[i]); bytes memory payload = abi.encode(_amount[i], msg.sender, _toAddress[i]); address payable refundAddress = (i == _dstChainId.length - 1) ? _refundAddress : payable(address(this)); _lzSend(_dstChainId[i], payload, refundAddress, _zroPaymentAddress, adapterParams, address(this).balance); emit SendGasDrop(_dstChainId[i], msg.sender, _toAddress[i], _amount[i]); } } /// @notice Update the destination gas amount. /// @param _dstGas The new destination gas amount. function setDstGas(uint _dstGas) external onlyOwner { dstGas = _dstGas; emit SetDstGas(dstGas); } /// @dev Fallback function to receive Ether. receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LzApp.sol"; import "../libraries/ExcessivelySafeCall.sol"; /* * the default LayerZero messaging behaviour is blocking, i.e. any failed message will block the channel * this abstract class try-catch all fail messages and store locally for future retry. hence, non-blocking * NOTE: if the srcAddress is not configured properly, it will still block the message pathway from (srcChainId, srcAddress) */ abstract contract NonblockingLzApp is LzApp { using ExcessivelySafeCall for address; constructor(address _endpoint) LzApp(_endpoint) {} mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) public failedMessages; event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload, bytes _reason); event RetryMessageSuccess(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _payloadHash); // overriding the virtual function in LzReceiver function _blockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual override { (bool success, bytes memory reason) = address(this).excessivelySafeCall( gasleft(), 150, abi.encodeWithSelector(this.nonblockingLzReceive.selector, _srcChainId, _srcAddress, _nonce, _payload) ); if (!success) { _storeFailedMessage(_srcChainId, _srcAddress, _nonce, _payload, reason); } } function _storeFailedMessage( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload, bytes memory _reason ) internal virtual { failedMessages[_srcChainId][_srcAddress][_nonce] = keccak256(_payload); emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload, _reason); } function nonblockingLzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload ) public virtual { // only internal transaction require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp"); _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } //@notice override this function function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual; function retryMessage( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload ) public payable virtual { // assert there is message to retry bytes32 payloadHash = failedMessages[_srcChainId][_srcAddress][_nonce]; require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message"); require(keccak256(_payload) == payloadHash, "NonblockingLzApp: invalid payload"); // clear the stored message failedMessages[_srcChainId][_srcAddress][_nonce] = bytes32(0); // execute the message. revert if it fails again _nonblockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); emit RetryMessageSuccess(_srcChainId, _srcAddress, _nonce, payloadHash); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "./interfaces/ILayerZeroReceiver.sol"; import "./interfaces/ILayerZeroUserApplicationConfig.sol"; import "./interfaces/ILayerZeroEndpoint.sol"; import "../libraries/BytesLib.sol"; /* * a generic LzReceiver implementation */ abstract contract LzApp is Ownable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig { using BytesLib for bytes; // ua can not send payload larger than this by default, but it can be changed by the ua owner uint public constant DEFAULT_PAYLOAD_SIZE_LIMIT = 10000; ILayerZeroEndpoint public immutable lzEndpoint; mapping(uint16 => bytes) public trustedRemoteLookup; mapping(uint16 => mapping(uint16 => uint)) public minDstGasLookup; mapping(uint16 => uint) public payloadSizeLimitLookup; address public precrime; event SetPrecrime(address precrime); event SetTrustedRemote(uint16 _remoteChainId, bytes _path); event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress); event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint _minDstGas); constructor(address _endpoint) { lzEndpoint = ILayerZeroEndpoint(_endpoint); } function lzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload ) public virtual override { // lzReceive must be called by the endpoint for security require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId]; // if will still block the message pathway from (srcChainId, srcAddress). should not receive message from untrusted remote. require( _srcAddress.length == trustedRemote.length && trustedRemote.length > 0 && keccak256(_srcAddress) == keccak256(trustedRemote), "LzApp: invalid source sending contract" ); _blockingLzReceive(_srcChainId, _srcAddress, _nonce, _payload); } // abstract function - the default behaviour of LayerZero is blocking. See: NonblockingLzApp if you dont need to enforce ordered messaging function _blockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual; function _lzSend( uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams, uint _nativeFee ) internal virtual { bytes memory trustedRemote = trustedRemoteLookup[_dstChainId]; require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source"); _checkPayloadSize(_dstChainId, _payload.length); lzEndpoint.send{value: _nativeFee}(_dstChainId, trustedRemote, _payload, _refundAddress, _zroPaymentAddress, _adapterParams); } function _checkGasLimit( uint16 _dstChainId, uint16 _type, bytes memory _adapterParams, uint _extraGas ) internal view virtual { uint providedGasLimit = _getGasLimit(_adapterParams); uint minGasLimit = minDstGasLookup[_dstChainId][_type]; require(minGasLimit > 0, "LzApp: minGasLimit not set"); require(providedGasLimit >= minGasLimit + _extraGas, "LzApp: gas limit is too low"); } function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint gasLimit) { require(_adapterParams.length >= 34, "LzApp: invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } function _checkPayloadSize(uint16 _dstChainId, uint _payloadSize) internal view virtual { uint payloadSizeLimit = payloadSizeLimitLookup[_dstChainId]; if (payloadSizeLimit == 0) { // use default if not set payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT; } require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large"); } //---------------------------UserApplication config---------------------------------------- function getConfig( uint16 _version, uint16 _chainId, address, uint _configType ) external view returns (bytes memory) { return lzEndpoint.getConfig(_version, _chainId, address(this), _configType); } // generic config for LayerZero user Application function setConfig( uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config ) external override onlyOwner { lzEndpoint.setConfig(_version, _chainId, _configType, _config); } function setSendVersion(uint16 _version) external override onlyOwner { lzEndpoint.setSendVersion(_version); } function setReceiveVersion(uint16 _version) external override onlyOwner { lzEndpoint.setReceiveVersion(_version); } function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external override onlyOwner { lzEndpoint.forceResumeReceive(_srcChainId, _srcAddress); } // _path = abi.encodePacked(remoteAddress, localAddress) // this function set the trusted path for the cross-chain communication function setTrustedRemote(uint16 _remoteChainId, bytes calldata _path) external onlyOwner { trustedRemoteLookup[_remoteChainId] = _path; emit SetTrustedRemote(_remoteChainId, _path); } function setTrustedRemoteAddress(uint16 _remoteChainId, bytes calldata _remoteAddress) external onlyOwner { trustedRemoteLookup[_remoteChainId] = abi.encodePacked(_remoteAddress, address(this)); emit SetTrustedRemoteAddress(_remoteChainId, _remoteAddress); } function getTrustedRemoteAddress(uint16 _remoteChainId) external view returns (bytes memory) { bytes memory path = trustedRemoteLookup[_remoteChainId]; require(path.length != 0, "LzApp: no trusted path record"); return path.slice(0, path.length - 20); // the last 20 bytes should be address(this) } function setPrecrime(address _precrime) external onlyOwner { precrime = _precrime; emit SetPrecrime(_precrime); } function setMinDstGas( uint16 _dstChainId, uint16 _packetType, uint _minGas ) external onlyOwner { minDstGasLookup[_dstChainId][_packetType] = _minGas; emit SetMinDstGas(_dstChainId, _packetType, _minGas); } // if the size is 0, it means default size limit function setPayloadSizeLimit(uint16 _dstChainId, uint _size) external onlyOwner { payloadSizeLimitLookup[_dstChainId] = _size; } //--------------------------- VIEW FUNCTION ---------------------------------------- function isTrustedRemote(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool) { bytes memory trustedSource = trustedRemoteLookup[_srcChainId]; return keccak256(trustedSource) == keccak256(_srcAddress); } }
// SPDX-License-Identifier: MIT OR Apache-2.0 pragma solidity >=0.7.6; library ExcessivelySafeCall { uint constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff; /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeCall( address _target, uint _gas, uint16 _maxCopy, bytes memory _calldata ) internal returns (bool, bytes memory) { // set up for assembly call uint _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := call( _gas, // gas _target, // recipient 0, // ether value add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /// @notice Use when you _really_ really _really_ don't trust the called /// contract. This prevents the called contract from causing reversion of /// the caller in as many ways as we can. /// @dev The main difference between this and a solidity low-level call is /// that we limit the number of bytes that the callee can cause to be /// copied to caller memory. This prevents stupid things like malicious /// contracts returning 10,000,000 bytes causing a local OOG when copying /// to memory. /// @param _target The address to call /// @param _gas The amount of gas to forward to the remote contract /// @param _maxCopy The maximum number of bytes of returndata to copy /// to memory. /// @param _calldata The data to send to the remote contract /// @return success and returndata, as `.call()`. Returndata is capped to /// `_maxCopy` bytes. function excessivelySafeStaticCall( address _target, uint _gas, uint16 _maxCopy, bytes memory _calldata ) internal view returns (bool, bytes memory) { // set up for assembly call uint _toCopy; bool _success; bytes memory _returnData = new bytes(_maxCopy); // dispatch message to recipient // by assembly calling "handle" function // we call via assembly to avoid memcopying a very large returndata // returned by a malicious contract assembly { _success := staticcall( _gas, // gas _target, // recipient add(_calldata, 0x20), // inloc mload(_calldata), // inlen 0, // outloc 0 // outlen ) // limit our copy to 256 bytes _toCopy := returndatasize() if gt(_toCopy, _maxCopy) { _toCopy := _maxCopy } // Store the length of the copied bytes mstore(_returnData, _toCopy) // copy the bytes from returndata[0:_toCopy] returndatacopy(add(_returnData, 0x20), 0, _toCopy) } return (_success, _returnData); } /** * @notice Swaps function selectors in encoded contract calls * @dev Allows reuse of encoded calldata for functions with identical * argument types but different names. It simply swaps out the first 4 bytes * for the new selector. This function modifies memory in place, and should * only be used with caution. * @param _newSelector The new 4-byte selector * @param _buf The encoded contract args */ function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure { require(_buf.length >= 4); uint _mask = LOW_28_MASK; assembly { // load the first word of let _word := mload(add(_buf, 0x20)) // mask out the top 4 bytes // /x _word := and(_word, _mask) _word := or(_newSelector, _word) mstore(add(_buf, 0x20), _word) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface ILayerZeroReceiver { // @notice LayerZero endpoint will invoke this function to deliver the message on the destination // @param _srcChainId - the source endpoint identifier // @param _srcAddress - the source sending contract address from the source chain // @param _nonce - the ordered message nonce // @param _payload - the signed payload is the UA bytes has encoded to be sent function lzReceive( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload ) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; interface ILayerZeroUserApplicationConfig { // @notice set the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _configType - type of configuration. every messaging library has its own convention. // @param _config - configuration in the bytes. can encode arbitrary content. function setConfig( uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config ) external; // @notice set the send() LayerZero messaging library version to _version // @param _version - new messaging library version function setSendVersion(uint16 _version) external; // @notice set the lzReceive() LayerZero messaging library version to _version // @param _version - new messaging library version function setReceiveVersion(uint16 _version) external; // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload // @param _srcChainId - the chainId of the source chain // @param _srcAddress - the contract address of the source contract at the source chain function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./ILayerZeroUserApplicationConfig.sol"; interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig { // @notice send a LayerZero message to the specified address at a LayerZero endpoint. // @param _dstChainId - the destination chain identifier // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains // @param _payload - a custom bytes payload to send to the destination contract // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination function send( uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; // @notice used by the messaging library to publish verified payload // @param _srcChainId - the source chain identifier // @param _srcAddress - the source contract (as bytes) at the source chain // @param _dstAddress - the address on destination chain // @param _nonce - the unbound message ordering nonce // @param _gasLimit - the gas limit for external contract execution // @param _payload - verified payload to send to the destination contract function receivePayload( uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload ) external; // @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64); // @notice get the outboundNonce from this source chain which, consequently, is always an EVM // @param _srcAddress - the source chain contract address function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64); // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery // @param _dstChainId - the destination chain identifier // @param _userApplication - the user app address on this EVM chain // @param _payload - the custom message to send over LayerZero // @param _payInZRO - if false, user app pays the protocol fee in native token // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain function estimateFees( uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam ) external view returns (uint nativeFee, uint zroFee); // @notice get this Endpoint's immutable source identifier function getChainId() external view returns (uint16); // @notice the interface to retry failed message on this Endpoint destination // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address // @param _payload - the payload to be retried function retryPayload( uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload ) external; // @notice query if any STORED payload (message blocking) at the endpoint. // @param _srcChainId - the source chain identifier // @param _srcAddress - the source chain contract address function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool); // @notice query if the _libraryAddress is valid for sending msgs. // @param _userApplication - the user app address on this EVM chain function getSendLibraryAddress(address _userApplication) external view returns (address); // @notice query if the _libraryAddress is valid for receiving msgs. // @param _userApplication - the user app address on this EVM chain function getReceiveLibraryAddress(address _userApplication) external view returns (address); // @notice query if the non-reentrancy guard for send() is on // @return true if the guard is on. false otherwise function isSendingPayload() external view returns (bool); // @notice query if the non-reentrancy guard for receive() is on // @return true if the guard is on. false otherwise function isReceivingPayload() external view returns (bool); // @notice get the configuration of the LayerZero messaging library of the specified version // @param _version - messaging library version // @param _chainId - the chainId for the pending config change // @param _userApplication - the contract address of the user application // @param _configType - type of configuration. every messaging library has its own convention. function getConfig( uint16 _version, uint16 _chainId, address _userApplication, uint _configType ) external view returns (bytes memory); // @notice get the send() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getSendVersion(address _userApplication) external view returns (uint16); // @notice get the lzReceive() LayerZero messaging library version // @param _userApplication - the contract address of the user application function getReceiveVersion(address _userApplication) external view returns (uint16); }
// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask))) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint _start) internal pure returns (uint) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
// 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.0; import "./interfaces/IONFT721Core.sol"; import "../../lzApp/NonblockingLzApp.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; abstract contract ONFT721Core is NonblockingLzApp, ERC165, ReentrancyGuard, IONFT721Core { uint16 public constant FUNCTION_TYPE_SEND = 1; struct StoredCredit { uint16 srcChainId; address toAddress; uint index; // which index of the tokenIds remain bool creditsRemain; } uint public minGasToTransferAndStore; // min amount of gas required to transfer, and also store the payload mapping(uint16 => uint) public dstChainIdToBatchLimit; mapping(uint16 => uint) public dstChainIdToTransferGas; // per transfer amount of gas required to mint/transfer on the dst mapping(bytes32 => StoredCredit) public storedCredits; constructor(uint _minGasToTransferAndStore, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) { require(_minGasToTransferAndStore > 0, "minGasToTransferAndStore must be > 0"); minGasToTransferAndStore = _minGasToTransferAndStore; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IONFT721Core).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee( uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, bool _useZro, bytes memory _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { return estimateSendBatchFee(_dstChainId, _toAddress, _toSingletonArray(_tokenId), _useZro, _adapterParams); } function estimateSendBatchFee( uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, bool _useZro, bytes memory _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { bytes memory payload = abi.encode(_toAddress, _tokenIds); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function sendFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) public payable virtual override { _send(_from, _dstChainId, _toAddress, _toSingletonArray(_tokenId), _refundAddress, _zroPaymentAddress, _adapterParams); } function sendBatchFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) public payable virtual override { _send(_from, _dstChainId, _toAddress, _tokenIds, _refundAddress, _zroPaymentAddress, _adapterParams); } function _send( address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual { // allow 1 by default require(_tokenIds.length > 0, "tokenIds[] is empty"); require(_tokenIds.length == 1 || _tokenIds.length <= dstChainIdToBatchLimit[_dstChainId], "batch size exceeds dst batch limit"); for (uint i = 0; i < _tokenIds.length; i++) { _debitFrom(_from, _dstChainId, _toAddress, _tokenIds[i]); } bytes memory payload = abi.encode(_toAddress, _tokenIds); _checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND, _adapterParams, dstChainIdToTransferGas[_dstChainId] * _tokenIds.length); _lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, _tokenIds); } function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64, /*_nonce*/ bytes memory _payload ) internal virtual override { // decode and load the toAddress (bytes memory toAddressBytes, uint[] memory tokenIds) = abi.decode(_payload, (bytes, uint[])); address toAddress; assembly { toAddress := mload(add(toAddressBytes, 20)) } uint nextIndex = _creditTill(_srcChainId, toAddress, 0, tokenIds); if (nextIndex < tokenIds.length) { // not enough gas to complete transfers, store to be cleared in another tx bytes32 hashedPayload = keccak256(_payload); storedCredits[hashedPayload] = StoredCredit(_srcChainId, toAddress, nextIndex, true); emit CreditStored(hashedPayload, _payload); } emit ReceiveFromChain(_srcChainId, _srcAddress, toAddress, tokenIds); } // Public function for anyone to clear and deliver the remaining batch sent tokenIds function clearCredits(bytes memory _payload) external virtual nonReentrant { bytes32 hashedPayload = keccak256(_payload); require(storedCredits[hashedPayload].creditsRemain, "no credits stored"); (, uint[] memory tokenIds) = abi.decode(_payload, (bytes, uint[])); uint nextIndex = _creditTill( storedCredits[hashedPayload].srcChainId, storedCredits[hashedPayload].toAddress, storedCredits[hashedPayload].index, tokenIds ); require(nextIndex > storedCredits[hashedPayload].index, "not enough gas to process credit transfer"); if (nextIndex == tokenIds.length) { // cleared the credits, delete the element delete storedCredits[hashedPayload]; emit CreditCleared(hashedPayload); } else { // store the next index to mint storedCredits[hashedPayload] = StoredCredit( storedCredits[hashedPayload].srcChainId, storedCredits[hashedPayload].toAddress, nextIndex, true ); } } // When a srcChain has the ability to transfer more chainIds in a single tx than the dst can do. // Needs the ability to iterate and stop if the minGasToTransferAndStore is not met function _creditTill( uint16 _srcChainId, address _toAddress, uint _startIndex, uint[] memory _tokenIds ) internal returns (uint) { uint i = _startIndex; while (i < _tokenIds.length) { // if not enough gas to process, store this index for next loop if (gasleft() < minGasToTransferAndStore) break; _creditTo(_srcChainId, _toAddress, _tokenIds[i]); i++; } // indicates the next index to send of tokenIds, // if i == tokenIds.length, we are finished return i; } function setMinGasToTransferAndStore(uint _minGasToTransferAndStore) external onlyOwner { require(_minGasToTransferAndStore > 0, "minGasToTransferAndStore must be > 0"); minGasToTransferAndStore = _minGasToTransferAndStore; emit SetMinGasToTransferAndStore(_minGasToTransferAndStore); } // ensures enough gas in adapter params to handle batch transfer gas amounts on the dst function setDstChainIdToTransferGas(uint16 _dstChainId, uint _dstChainIdToTransferGas) external onlyOwner { require(_dstChainIdToTransferGas > 0, "dstChainIdToTransferGas must be > 0"); dstChainIdToTransferGas[_dstChainId] = _dstChainIdToTransferGas; emit SetDstChainIdToTransferGas(_dstChainId, _dstChainIdToTransferGas); } // limit on src the amount of tokens to batch send function setDstChainIdToBatchLimit(uint16 _dstChainId, uint _dstChainIdToBatchLimit) external onlyOwner { require(_dstChainIdToBatchLimit > 0, "dstChainIdToBatchLimit must be > 0"); dstChainIdToBatchLimit[_dstChainId] = _dstChainIdToBatchLimit; emit SetDstChainIdToBatchLimit(_dstChainId, _dstChainIdToBatchLimit); } function _debitFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId ) internal virtual; function _creditTo( uint16 _srcChainId, address _toAddress, uint _tokenId ) internal virtual; function _toSingletonArray(uint element) internal pure returns (uint[] memory) { uint[] memory array = new uint[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the ONFT Core standard */ interface IONFT721Core is IERC165 { /** * @dev Emitted when `_tokenIds[]` are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce from */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes indexed _toAddress, uint[] _tokenIds); event ReceiveFromChain(uint16 indexed _srcChainId, bytes indexed _srcAddress, address indexed _toAddress, uint[] _tokenIds); event SetMinGasToTransferAndStore(uint _minGasToTransferAndStore); event SetDstChainIdToTransferGas(uint16 _dstChainId, uint _dstChainIdToTransferGas); event SetDstChainIdToBatchLimit(uint16 _dstChainId, uint _dstChainIdToBatchLimit); /** * @dev Emitted when `_payload` was received from lz, but not enough gas to deliver all tokenIds */ event CreditStored(bytes32 _hashedPayload, bytes _payload); /** * @dev Emitted when `_hashedPayload` has been completely delivered */ event CreditCleared(bytes32 _hashedPayload); /** * @dev send token `_tokenId` to (`_dstChainId`, `_toAddress`) from `_from` * `_toAddress` can be any size depending on the `dstChainId`. * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; /** * @dev send tokens `_tokenIds[]` to (`_dstChainId`, `_toAddress`) from `_from` * `_toAddress` can be any size depending on the `dstChainId`. * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendBatchFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _tokenId - token Id to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParams - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee( uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, bool _useZro, bytes calldata _adapterParams ) external view returns (uint nativeFee, uint zroFee); /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _tokenIds[] - token Ids to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParams - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendBatchFee( uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, bool _useZro, bytes calldata _adapterParams ) external view returns (uint nativeFee, uint zroFee); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
// 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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; import "./ONFT721Core.sol"; contract ProxyONFT721 is ONFT721Core, IERC721Receiver { using ERC165Checker for address; IERC721 public immutable token; constructor( uint _minGasToTransfer, address _lzEndpoint, address _proxyToken ) ONFT721Core(_minGasToTransfer, _lzEndpoint) { require(_proxyToken.supportsInterface(type(IERC721).interfaceId), "ProxyONFT721: invalid ERC721 token"); token = IERC721(_proxyToken); } function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC721Receiver).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom( address _from, uint16, bytes memory, uint _tokenId ) internal virtual override { require(_from == _msgSender(), "ProxyONFT721: owner is not send caller"); token.safeTransferFrom(_from, address(this), _tokenId); } // TODO apply same changes from regular ONFT721 function _creditTo( uint16, address _toAddress, uint _tokenId ) internal virtual override { token.safeTransferFrom(address(this), _toAddress, _tokenId); } function onERC721Received( address _operator, address, uint, bytes memory ) public virtual override returns (bytes4) { // only allow `this` to transfer token from others if (_operator != address(this)) return bytes4(0); return IERC721Receiver.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Library used to query support of an interface declared via {IERC165}. * * Note that these functions return the actual result of the query: they do not * `revert` if an interface is not supported. It is up to the caller to decide * what to do in these cases. */ library ERC165Checker { // As per the EIP-165 spec, no interface should ever match 0xffffffff bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; /** * @dev Returns true if `account` supports the {IERC165} interface. */ function supportsERC165(address account) internal view returns (bool) { // Any contract that implements ERC165 must explicitly indicate support of // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid return supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) && !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID); } /** * @dev Returns true if `account` supports the interface defined by * `interfaceId`. Support for {IERC165} itself is queried automatically. * * See {IERC165-supportsInterface}. */ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { // query support of both ERC165 as per the spec and support of _interfaceId return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId); } /** * @dev Returns a boolean array where each value corresponds to the * interfaces passed in and whether they're supported or not. This allows * you to batch check interfaces for a contract where your expectation * is that some interfaces may not be supported. * * See {IERC165-supportsInterface}. * * _Available since v3.4._ */ function getSupportedInterfaces( address account, bytes4[] memory interfaceIds ) internal view returns (bool[] memory) { // an array of booleans corresponding to interfaceIds and whether they're supported or not bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length); // query support of ERC165 itself if (supportsERC165(account)) { // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]); } } return interfaceIdsSupported; } /** * @dev Returns true if `account` supports all the interfaces defined in * `interfaceIds`. Support for {IERC165} itself is queried automatically. * * Batch-querying can lead to gas savings by skipping repeated checks for * {IERC165} support. * * See {IERC165-supportsInterface}. */ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { // query support of ERC165 itself if (!supportsERC165(account)) { return false; } // query support of each interface in interfaceIds for (uint256 i = 0; i < interfaceIds.length; i++) { if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) { return false; } } // all interfaces supported return true; } /** * @notice Query if a contract implements an interface, does not check ERC165 support * @param account The address of the contract to query for support of an interface * @param interfaceId The interface identifier, as specified in ERC-165 * @return true if the contract at account indicates support of the interface with * identifier interfaceId, false otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise * the behavior of this method is undefined. This precondition can be checked * with {supportsERC165}. * * Some precompiled contracts will falsely indicate support for a given interface, so caution * should be exercised when using this function. * * Interface identification is specified in ERC-165. */ function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) { // prepare call bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId); // perform static call bool success; uint256 returnSize; uint256 returnValue; assembly { success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20) returnSize := returndatasize() returnValue := mload(0x00) } return success && returnSize >= 0x20 && returnValue > 0; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "erc721a/contracts/ERC721A.sol"; import "erc721a/contracts/IERC721A.sol"; import "./interfaces/IONFT721.sol"; import "./ONFT721Core.sol"; // DISCLAIMER: // This contract can only be deployed on one chain and must be the first minter of each token id! // This is because ERC721A does not have the ability to mint a specific token id. // Other chains must have ONFT721 deployed. // NOTE: this ONFT contract has no public minting logic. // must implement your own minting logic in child contract contract ONFT721A is ONFT721Core, ERC721A, ERC721A__IERC721Receiver { constructor( string memory _name, string memory _symbol, uint _minGasToTransferAndStore, address _lzEndpoint ) ERC721A(_name, _symbol) ONFT721Core(_minGasToTransferAndStore, _lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT721Core, ERC721A) returns (bool) { return interfaceId == type(IONFT721Core).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom( address _from, uint16, bytes memory, uint _tokenId ) internal virtual override(ONFT721Core) { safeTransferFrom(_from, address(this), _tokenId); } function _creditTo( uint16, address _toAddress, uint _tokenId ) internal virtual override(ONFT721Core) { require(_exists(_tokenId) && ERC721A.ownerOf(_tokenId) == address(this)); safeTransferFrom(address(this), _toAddress, _tokenId); } function onERC721Received( address, address, uint, bytes memory ) public virtual override returns (bytes4) { return ERC721A__IERC721Receiver.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721A.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721A is IERC721A { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 private _currentIndex; // The number of tokens burned. uint256 private _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) private _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) private _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => TokenApprovalRef) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // ============================================================= // CONSTRUCTOR // ============================================================= constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return _currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return _currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return _burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(_packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = _packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); _packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (_packedOwnerships[index] == 0) { _packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { uint256 packed = _packedOwnerships[curr]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `curr` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. while (packed == 0) { packed = _packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) public payable virtual override { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } _tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override { _operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && // If within bounds, _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public payable virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns ( bytes4 retval ) { return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); _currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. _packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); _currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = _currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (_currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = _packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); _packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721A { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./IONFT721Core.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @dev Interface of the ONFT standard */ interface IONFT721 is IONFT721Core, IERC721 { }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IONFT721.sol"; import "./ONFT721Core.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; // NOTE: this ONFT contract has no public minting logic. // must implement your own minting logic in child classes contract ONFT721 is ONFT721Core, ERC721, IONFT721 { constructor( string memory _name, string memory _symbol, uint _minGasToTransfer, address _lzEndpoint ) ERC721(_name, _symbol) ONFT721Core(_minGasToTransfer, _lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT721Core, ERC721, IERC165) returns (bool) { return interfaceId == type(IONFT721).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom( address _from, uint16, bytes memory, uint _tokenId ) internal virtual override { require(_isApprovedOrOwner(_msgSender(), _tokenId), "ONFT721: send caller is not owner nor approved"); require(ERC721.ownerOf(_tokenId) == _from, "ONFT721: send from incorrect owner"); _transfer(_from, address(this), _tokenId); } function _creditTo( uint16, address _toAddress, uint _tokenId ) internal virtual override { require(!_exists(_tokenId) || (_exists(_tokenId) && ERC721.ownerOf(_tokenId) == address(this))); if (!_exists(_tokenId)) { _safeMint(_toAddress, _tokenId); } else { _transfer(address(this), _toAddress, _tokenId); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _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) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _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); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IONFT1155Core.sol"; import "../../lzApp/NonblockingLzApp.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract ONFT1155Core is NonblockingLzApp, ERC165, IONFT1155Core { uint public constant NO_EXTRA_GAS = 0; uint16 public constant FUNCTION_TYPE_SEND = 1; uint16 public constant FUNCTION_TYPE_SEND_BATCH = 2; bool public useCustomAdapterParams; event SetUseCustomAdapterParams(bool _useCustomAdapterParams); constructor(address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IONFT1155Core).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee( uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, uint _amount, bool _useZro, bytes memory _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { return estimateSendBatchFee(_dstChainId, _toAddress, _toSingletonArray(_tokenId), _toSingletonArray(_amount), _useZro, _adapterParams); } function estimateSendBatchFee( uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, bool _useZro, bytes memory _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { bytes memory payload = abi.encode(_toAddress, _tokenIds, _amounts); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function sendFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _tokenId, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) public payable virtual override { _sendBatch( _from, _dstChainId, _toAddress, _toSingletonArray(_tokenId), _toSingletonArray(_amount), _refundAddress, _zroPaymentAddress, _adapterParams ); } function sendBatchFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) public payable virtual override { _sendBatch(_from, _dstChainId, _toAddress, _tokenIds, _amounts, _refundAddress, _zroPaymentAddress, _adapterParams); } function _sendBatch( address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, uint[] memory _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual { _debitFrom(_from, _dstChainId, _toAddress, _tokenIds, _amounts); bytes memory payload = abi.encode(_toAddress, _tokenIds, _amounts); if (_tokenIds.length == 1) { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND, _adapterParams, NO_EXTRA_GAS); } else { require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty."); } _lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, _tokenIds[0], _amounts[0]); } else if (_tokenIds.length > 1) { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, FUNCTION_TYPE_SEND_BATCH, _adapterParams, NO_EXTRA_GAS); } else { require(_adapterParams.length == 0, "LzApp: _adapterParams must be empty."); } _lzSend(_dstChainId, payload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendBatchToChain(_dstChainId, _from, _toAddress, _tokenIds, _amounts); } } function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64, /*_nonce*/ bytes memory _payload ) internal virtual override { // decode and load the toAddress (bytes memory toAddressBytes, uint[] memory tokenIds, uint[] memory amounts) = abi.decode(_payload, (bytes, uint[], uint[])); address toAddress; assembly { toAddress := mload(add(toAddressBytes, 20)) } _creditTo(_srcChainId, toAddress, tokenIds, amounts); if (tokenIds.length == 1) { emit ReceiveFromChain(_srcChainId, _srcAddress, toAddress, tokenIds[0], amounts[0]); } else if (tokenIds.length > 1) { emit ReceiveBatchFromChain(_srcChainId, _srcAddress, toAddress, tokenIds, amounts); } } function setUseCustomAdapterParams(bool _useCustomAdapterParams) external onlyOwner { useCustomAdapterParams = _useCustomAdapterParams; emit SetUseCustomAdapterParams(_useCustomAdapterParams); } function _debitFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual; function _creditTo( uint16 _srcChainId, address _toAddress, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual; function _toSingletonArray(uint element) internal pure returns (uint[] memory) { uint[] memory array = new uint[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the ONFT Core standard */ interface IONFT1155Core is IERC165 { event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes indexed _toAddress, uint _tokenId, uint _amount); event SendBatchToChain(uint16 indexed _dstChainId, address indexed _from, bytes indexed _toAddress, uint[] _tokenIds, uint[] _amounts); event ReceiveFromChain(uint16 indexed _srcChainId, bytes indexed _srcAddress, address indexed _toAddress, uint _tokenId, uint _amount); event ReceiveBatchFromChain( uint16 indexed _srcChainId, bytes indexed _srcAddress, address indexed _toAddress, uint[] _tokenIds, uint[] _amounts ); // _from - address where tokens should be deducted from on behalf of // _dstChainId - L0 defined chain id to send tokens too // _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain // _tokenId - token Id to transfer // _amount - amount of the tokens to transfer // _refundAddress - address on src that will receive refund for any overpayment of L0 fees // _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro // _adapterParams - flexible bytes array to indicate messaging adapter services in L0 function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; // _from - address where tokens should be deducted from on behalf of // _dstChainId - L0 defined chain id to send tokens too // _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain // _tokenIds - token Ids to transfer // _amounts - amounts of the tokens to transfer // _refundAddress - address on src that will receive refund for any overpayment of L0 fees // _zroPaymentAddress - if paying in zro, pass the address to use. using 0x0 indicates not paying fees in zro // _adapterParams - flexible bytes array to indicate messaging adapter services in L0 function sendBatchFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, uint[] calldata _amounts, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) external payable; // _dstChainId - L0 defined chain id to send tokens too // _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain // _tokenId - token Id to transfer // _amount - amount of the tokens to transfer // _useZro - indicates to use zro to pay L0 fees // _adapterParams - flexible bytes array to indicate messaging adapter services in L0 function estimateSendFee( uint16 _dstChainId, bytes calldata _toAddress, uint _tokenId, uint _amount, bool _useZro, bytes calldata _adapterParams ) external view returns (uint nativeFee, uint zroFee); // _dstChainId - L0 defined chain id to send tokens too // _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain // _tokenIds - tokens Id to transfer // _amounts - amounts of the tokens to transfer // _useZro - indicates to use zro to pay L0 fees // _adapterParams - flexible bytes array to indicate messaging adapter services in L0 function estimateSendBatchFee( uint16 _dstChainId, bytes calldata _toAddress, uint[] calldata _tokenIds, uint[] calldata _amounts, bool _useZro, bytes calldata _adapterParams ) external view returns (uint nativeFee, uint zroFee); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./ONFT1155Core.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; contract ProxyONFT1155 is ONFT1155Core, IERC1155Receiver { using ERC165Checker for address; IERC1155 public immutable token; constructor(address _lzEndpoint, address _proxyToken) ONFT1155Core(_lzEndpoint) { require(_proxyToken.supportsInterface(type(IERC1155).interfaceId), "ProxyONFT1155: invalid ERC1155 token"); token = IERC1155(_proxyToken); } function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT1155Core, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom( address _from, uint16, bytes memory, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual override { require(_from == _msgSender(), "ProxyONFT1155: owner is not send caller"); token.safeBatchTransferFrom(_from, address(this), _tokenIds, _amounts, ""); } function _creditTo( uint16, address _toAddress, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual override { token.safeBatchTransferFrom(address(this), _toAddress, _tokenIds, _amounts, ""); } function onERC1155Received( address _operator, address, uint, uint, bytes memory ) public virtual override returns (bytes4) { // only allow `this` to tranfser token from others if (_operator != address(this)) return bytes4(0); return this.onERC1155Received.selector; } function onERC1155BatchReceived( address _operator, address, uint[] memory, uint[] memory, bytes memory ) public virtual override returns (bytes4) { // only allow `this` to tranfser token from others if (_operator != address(this)) return bytes4(0); return this.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn(address from, uint256 id, uint256 amount) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory amounts) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IONFT1155.sol"; import "./ONFT1155Core.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; // NOTE: this ONFT contract has no public minting logic. // must implement your own minting logic in child classes contract ONFT1155 is ONFT1155Core, ERC1155, IONFT1155 { constructor(string memory _uri, address _lzEndpoint) ERC1155(_uri) ONFT1155Core(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ONFT1155Core, ERC1155, IERC165) returns (bool) { return interfaceId == type(IONFT1155).interfaceId || super.supportsInterface(interfaceId); } function _debitFrom( address _from, uint16, bytes memory, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual override { address spender = _msgSender(); require(spender == _from || isApprovedForAll(_from, spender), "ONFT1155: send caller is not owner nor approved"); _burnBatch(_from, _tokenIds, _amounts); } function _creditTo( uint16, address _toAddress, uint[] memory _tokenIds, uint[] memory _amounts ) internal virtual override { _mintBatch(_toAddress, _tokenIds, _amounts, ""); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./IONFT1155Core.sol"; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; /** * @dev Interface of the ONFT standard */ interface IONFT1155 is IONFT1155Core, IERC1155 { }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer(address from, address to, uint256 amount) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve(address owner, address spender, uint256 amount) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 amount) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./OFTCoreV2.sol"; import "./interfaces/IOFTV2.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract BaseOFTV2 is OFTCoreV2, ERC165, IOFTV2 { constructor(uint8 _sharedDecimals, address _lzEndpoint) OFTCoreV2(_sharedDecimals, _lzEndpoint) {} /************************************************************************ * public functions ************************************************************************/ function sendFrom( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams ) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); } function sendAndCall( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams ) public payable virtual override { _sendAndCall( _from, _dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams ); } /************************************************************************ * public view functions ************************************************************************/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTV2).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee( uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendFee(_dstChainId, _toAddress, _amount, _useZro, _adapterParams); } function estimateSendAndCallFee( uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendAndCallFee(_dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _useZro, _adapterParams); } function circulatingSupply() public view virtual override returns (uint); function token() public view virtual override returns (address); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../../lzApp/NonblockingLzApp.sol"; import "../../../libraries/ExcessivelySafeCall.sol"; import "./interfaces/ICommonOFT.sol"; import "./interfaces/IOFTReceiverV2.sol"; abstract contract OFTCoreV2 is NonblockingLzApp { using BytesLib for bytes; using ExcessivelySafeCall for address; uint public constant NO_EXTRA_GAS = 0; // packet type uint8 public constant PT_SEND = 0; uint8 public constant PT_SEND_AND_CALL = 1; uint8 public immutable sharedDecimals; mapping(uint16 => mapping(bytes => mapping(uint64 => bool))) public creditedPackets; /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes32 indexed _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event CallOFTReceivedSuccess(uint16 indexed _srcChainId, bytes _srcAddress, uint64 _nonce, bytes32 _hash); event NonContractAddress(address _address); // _sharedDecimals should be the minimum decimals on all chains constructor(uint8 _sharedDecimals, address _lzEndpoint) NonblockingLzApp(_lzEndpoint) { sharedDecimals = _sharedDecimals; } /************************************************************************ * public functions ************************************************************************/ function callOnOFTReceived( uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes32 _from, address _to, uint _amount, bytes calldata _payload, uint _gasForCall ) public virtual { require(_msgSender() == address(this), "OFTCore: caller must be OFTCore"); // send _amount = _transferFrom(address(this), _to, _amount); emit ReceiveFromChain(_srcChainId, _to, _amount); // call IOFTReceiverV2(_to).onOFTReceived{gas: _gasForCall}(_srcChainId, _srcAddress, _nonce, _from, _amount, _payload); } /************************************************************************ * internal functions ************************************************************************/ function _estimateSendFee( uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes memory _adapterParams ) internal view virtual returns (uint nativeFee, uint zroFee) { // mock the payload for sendFrom() bytes memory payload = _encodeSendPayload(_toAddress, _ld2sd(_amount)); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function _estimateSendAndCallFee( uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, bool _useZro, bytes memory _adapterParams ) internal view virtual returns (uint nativeFee, uint zroFee) { // mock the payload for sendAndCall() bytes memory payload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(_amount), _payload, _dstGasForCall); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual override { uint8 packetType = _payload.toUint8(0); if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else if (packetType == PT_SEND_AND_CALL) { _sendAndCallAck(_srcChainId, _srcAddress, _nonce, _payload); } else { revert("OFTCore: unknown packet type"); } } function _send( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); (amount, ) = _removeDust(_amount); amount = _debitFrom(_from, _dstChainId, _toAddress, amount); // amount returned should not have dust require(amount > 0, "OFTCore: amount too small"); bytes memory lzPayload = _encodeSendPayload(_toAddress, _ld2sd(amount)); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAck( uint16 _srcChainId, bytes memory, uint64, bytes memory _payload ) internal virtual { (address to, uint64 amountSD) = _decodeSendPayload(_payload); if (to == address(0)) { to = address(0xdead); } uint amount = _sd2ld(amountSD); amount = _creditTo(_srcChainId, to, amount); emit ReceiveFromChain(_srcChainId, to, amount); } function _sendAndCall( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND_AND_CALL, _adapterParams, _dstGasForCall); (amount, ) = _removeDust(_amount); amount = _debitFrom(_from, _dstChainId, _toAddress, amount); require(amount > 0, "OFTCore: amount too small"); // encode the msg.sender into the payload instead of _from bytes memory lzPayload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(amount), _payload, _dstGasForCall); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAndCallAck( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual { (bytes32 from, address to, uint64 amountSD, bytes memory payloadForCall, uint64 gasForCall) = _decodeSendAndCallPayload(_payload); bool credited = creditedPackets[_srcChainId][_srcAddress][_nonce]; uint amount = _sd2ld(amountSD); // credit to this contract first, and then transfer to receiver only if callOnOFTReceived() succeeds if (!credited) { amount = _creditTo(_srcChainId, address(this), amount); creditedPackets[_srcChainId][_srcAddress][_nonce] = true; } if (!_isContract(to)) { emit NonContractAddress(to); return; } // workaround for stack too deep uint16 srcChainId = _srcChainId; bytes memory srcAddress = _srcAddress; uint64 nonce = _nonce; bytes memory payload = _payload; bytes32 from_ = from; address to_ = to; uint amount_ = amount; bytes memory payloadForCall_ = payloadForCall; // no gas limit for the call if retry uint gas = credited ? gasleft() : gasForCall; (bool success, bytes memory reason) = address(this).excessivelySafeCall( gasleft(), 150, abi.encodeWithSelector(this.callOnOFTReceived.selector, srcChainId, srcAddress, nonce, from_, to_, amount_, payloadForCall_, gas) ); if (success) { bytes32 hash = keccak256(payload); emit CallOFTReceivedSuccess(srcChainId, srcAddress, nonce, hash); } else { // store the failed message into the nonblockingLzApp _storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason); } } function _isContract(address _account) internal view returns (bool) { return _account.code.length > 0; } function _ld2sd(uint _amount) internal view virtual returns (uint64) { uint amountSD = _amount / _ld2sdRate(); require(amountSD <= type(uint64).max, "OFTCore: amountSD overflow"); return uint64(amountSD); } function _sd2ld(uint64 _amountSD) internal view virtual returns (uint) { return _amountSD * _ld2sdRate(); } function _removeDust(uint _amount) internal view virtual returns (uint amountAfter, uint dust) { dust = _amount % _ld2sdRate(); amountAfter = _amount - dust; } function _encodeSendPayload(bytes32 _toAddress, uint64 _amountSD) internal view virtual returns (bytes memory) { return abi.encodePacked(PT_SEND, _toAddress, _amountSD); } function _decodeSendPayload(bytes memory _payload) internal view virtual returns (address to, uint64 amountSD) { require(_payload.toUint8(0) == PT_SEND && _payload.length == 41, "OFTCore: invalid payload"); to = _payload.toAddress(13); // drop the first 12 bytes of bytes32 amountSD = _payload.toUint64(33); } function _encodeSendAndCallPayload( address _from, bytes32 _toAddress, uint64 _amountSD, bytes memory _payload, uint64 _dstGasForCall ) internal view virtual returns (bytes memory) { return abi.encodePacked(PT_SEND_AND_CALL, _toAddress, _amountSD, _addressToBytes32(_from), _dstGasForCall, _payload); } function _decodeSendAndCallPayload(bytes memory _payload) internal view virtual returns ( bytes32 from, address to, uint64 amountSD, bytes memory payload, uint64 dstGasForCall ) { require(_payload.toUint8(0) == PT_SEND_AND_CALL, "OFTCore: invalid payload"); to = _payload.toAddress(13); // drop the first 12 bytes of bytes32 amountSD = _payload.toUint64(33); from = _payload.toBytes32(41); dstGasForCall = _payload.toUint64(73); payload = _payload.slice(81, _payload.length - 81); } function _addressToBytes32(address _address) internal pure virtual returns (bytes32) { return bytes32(uint(uint160(_address))); } function _debitFrom( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount ) internal virtual returns (uint); function _creditTo( uint16 _srcChainId, address _toAddress, uint _amount ) internal virtual returns (uint); function _transferFrom( address _from, address _to, uint _amount ) internal virtual returns (uint); function _ld2sdRate() internal view virtual returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./ICommonOFT.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTV2 is ICommonOFT { /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) external payable; function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable; }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the IOFT core standard */ interface ICommonOFT is IERC165 { struct LzCallParams { address payable refundAddress; address zroPaymentAddress; bytes adapterParams; } /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; interface IOFTReceiverV2 { /** * @dev Called by the OFT contract when tokens are received from source chain. * @param _srcChainId The chain id of the source chain. * @param _srcAddress The address of the OFT token contract on the source chain. * @param _nonce The nonce of the transaction on the source chain. * @param _from The address of the account who calls the sendAndCall() on the source chain. * @param _amount The amount of tokens to transfer. * @param _payload Additional data with no specified format. */ function onOFTReceived(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes32 _from, uint _amount, bytes calldata _payload) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./OFTV2.sol"; contract NativeOFTV2 is OFTV2, ReentrancyGuard { event Deposit(address indexed _dst, uint _amount); event Withdrawal(address indexed _src, uint _amount); constructor( string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint ) OFTV2(_name, _symbol, _sharedDecimals, _lzEndpoint) {} /************************************************************************ * public functions ************************************************************************/ function sendFrom( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams ) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); } function sendAndCall( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams ) public payable virtual override { _sendAndCall( _from, _dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams ); } function deposit() public payable { _mint(msg.sender, msg.value); emit Deposit(msg.sender, msg.value); } function withdraw(uint _amount) external nonReentrant { require(balanceOf(msg.sender) >= _amount, "NativeOFTV2: Insufficient balance."); _burn(msg.sender, _amount); (bool success, ) = msg.sender.call{value: _amount}(""); require(success, "NativeOFTV2: failed to unwrap"); emit Withdrawal(msg.sender, _amount); } function _send( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual override returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); (amount, ) = _removeDust(_amount); require(amount > 0, "NativeOFTV2: amount too small"); uint messageFee = _debitFromNative(_from, amount); bytes memory lzPayload = _encodeSendPayload(_toAddress, _ld2sd(amount)); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, messageFee); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAndCall( address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual override returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND_AND_CALL, _adapterParams, _dstGasForCall); (amount, ) = _removeDust(_amount); require(amount > 0, "NativeOFTV2: amount too small"); uint messageFee = _debitFromNative(_from, amount); // encode the msg.sender into the payload instead of _from bytes memory lzPayload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(amount), _payload, _dstGasForCall); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, messageFee); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _debitFromNative(address _from, uint _amount) internal returns (uint messageFee) { messageFee = msg.sender == _from ? _debitMsgSender(_amount) : _debitMsgFrom(_from, _amount); } function _debitMsgSender(uint _amount) internal returns (uint messageFee) { uint msgSenderBalance = balanceOf(msg.sender); if (msgSenderBalance < _amount) { require(msgSenderBalance + msg.value >= _amount, "NativeOFTV2: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgSenderBalance; _mint(address(msg.sender), mintAmount); // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _transfer(msg.sender, address(this), _amount); return messageFee; } function _debitMsgFrom(address _from, uint _amount) internal returns (uint messageFee) { uint msgFromBalance = balanceOf(_from); if (msgFromBalance < _amount) { require(msgFromBalance + msg.value >= _amount, "NativeOFTV2: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgFromBalance; _mint(address(msg.sender), mintAmount); // transfer the differential amount to the contract _transfer(msg.sender, address(this), mintAmount); // overwrite the _amount to take the rest of the balance from the _from address _amount = msgFromBalance; // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _spendAllowance(_from, msg.sender, _amount); _transfer(_from, address(this), _amount); return messageFee; } function _creditTo( uint16, address _toAddress, uint _amount ) internal override returns (uint) { _burn(address(this), _amount); (bool success, ) = _toAddress.call{value: _amount}(""); require(success, "NativeOFTV2: failed to _creditTo"); return _amount; } receive() external payable { deposit(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./OFTWithFee.sol"; contract NativeOFTWithFee is OFTWithFee, ReentrancyGuard { event Deposit(address indexed _dst, uint _amount); event Withdrawal(address indexed _src, uint _amount); constructor(string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint) OFTWithFee(_name, _symbol, _sharedDecimals, _lzEndpoint) {} function deposit() public payable { _mint(msg.sender, msg.value); emit Deposit(msg.sender, msg.value); } function withdraw(uint _amount) external nonReentrant { require(balanceOf(msg.sender) >= _amount, "NativeOFTWithFee: Insufficient balance."); _burn(msg.sender, _amount); (bool success, ) = msg.sender.call{value: _amount}(""); require(success, "NativeOFTWithFee: failed to unwrap"); emit Withdrawal(msg.sender, _amount); } function _send(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual override returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); (amount,) = _removeDust(_amount); require(amount > 0, "NativeOFTWithFee: amount too small"); uint messageFee = _debitFromNative(_from, amount); bytes memory lzPayload = _encodeSendPayload(_toAddress, _ld2sd(amount)); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, messageFee); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes memory _payload, uint64 _dstGasForCall, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams) internal virtual override returns (uint amount) { _checkGasLimit(_dstChainId, PT_SEND_AND_CALL, _adapterParams, _dstGasForCall); (amount,) = _removeDust(_amount); require(amount > 0, "NativeOFTWithFee: amount too small"); uint messageFee = _debitFromNative(_from, amount); // encode the msg.sender into the payload instead of _from bytes memory lzPayload = _encodeSendAndCallPayload(msg.sender, _toAddress, _ld2sd(amount), _payload, _dstGasForCall); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, messageFee); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _debitFromNative(address _from, uint _amount) internal returns (uint messageFee) { messageFee = msg.sender == _from ? _debitMsgSender(_amount) : _debitMsgFrom(_from, _amount); } function _debitMsgSender(uint _amount) internal returns (uint messageFee) { uint msgSenderBalance = balanceOf(msg.sender); if (msgSenderBalance < _amount) { require(msgSenderBalance + msg.value >= _amount, "NativeOFTWithFee: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgSenderBalance; _mint(address(msg.sender), mintAmount); // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _transfer(msg.sender, address(this), _amount); return messageFee; } function _debitMsgFrom(address _from, uint _amount) internal returns (uint messageFee) { uint msgFromBalance = balanceOf(_from); if (msgFromBalance < _amount) { require(msgFromBalance + msg.value >= _amount, "NativeOFTWithFee: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgFromBalance; _mint(address(msg.sender), mintAmount); // transfer the differential amount to the contract _transfer(msg.sender, address(this), mintAmount); // overwrite the _amount to take the rest of the balance from the _from address _amount = msgFromBalance; // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _spendAllowance(_from, msg.sender, _amount); _transfer(_from, address(this), _amount); return messageFee; } function _creditTo(uint16, address _toAddress, uint _amount) internal override returns(uint) { _burn(address(this), _amount); (bool success, ) = _toAddress.call{value: _amount}(""); require(success, "NativeOFTWithFee: failed to _creditTo"); return _amount; } receive() external payable { deposit(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "./BaseOFTWithFee.sol"; contract OFTWithFee is BaseOFTWithFee, ERC20 { uint internal immutable ld2sdRate; constructor(string memory _name, string memory _symbol, uint8 _sharedDecimals, address _lzEndpoint) ERC20(_name, _symbol) BaseOFTWithFee(_sharedDecimals, _lzEndpoint) { uint8 decimals = decimals(); require(_sharedDecimals <= decimals, "OFTWithFee: sharedDecimals must be <= decimals"); ld2sdRate = 10 ** (decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function token() public view virtual override returns (address) { return address(this); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom(address _from, uint16, bytes32, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns (uint) { _mint(_toAddress, _amount); return _amount; } function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) { address spender = _msgSender(); // if transfer from this contract, no need to check allowance if (_from != address(this) && _from != spender) _spendAllowance(_from, spender, _amount); _transfer(_from, _to, _amount); return _amount; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../OFTCoreV2.sol"; import "./IOFTWithFee.sol"; import "./Fee.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract BaseOFTWithFee is OFTCoreV2, Fee, ERC165, IOFTWithFee { constructor(uint8 _sharedDecimals, address _lzEndpoint) OFTCoreV2(_sharedDecimals, _lzEndpoint) { } /************************************************************************ * public functions ************************************************************************/ function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, LzCallParams calldata _callParams) public payable virtual override { (_amount,) = _payOFTFee(_from, _dstChainId, _amount); _amount = _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); require(_amount >= _minAmount, "BaseOFTWithFee: amount is less than minAmount"); } function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) public payable virtual override { (_amount,) = _payOFTFee(_from, _dstChainId, _amount); _amount = _sendAndCall(_from, _dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); require(_amount >= _minAmount, "BaseOFTWithFee: amount is less than minAmount"); } /************************************************************************ * public view functions ************************************************************************/ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTWithFee).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendFee(_dstChainId, _toAddress, _amount, _useZro, _adapterParams); } function estimateSendAndCallFee(uint16 _dstChainId, bytes32 _toAddress, uint _amount, bytes calldata _payload, uint64 _dstGasForCall, bool _useZro, bytes calldata _adapterParams) public view virtual override returns (uint nativeFee, uint zroFee) { return _estimateSendAndCallFee(_dstChainId, _toAddress, _amount, _payload, _dstGasForCall, _useZro, _adapterParams); } function circulatingSupply() public view virtual override returns (uint); function token() public view virtual override returns (address); function _transferFrom(address _from, address _to, uint _amount) internal virtual override (Fee, OFTCoreV2) returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "../interfaces/ICommonOFT.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTWithFee is ICommonOFT { /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_minAmount` the minimum amount of tokens to receive on dstChain * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, LzCallParams calldata _callParams) external payable; function sendAndCall(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, uint _minAmount, bytes calldata _payload, uint64 _dstGasForCall, LzCallParams calldata _callParams) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; abstract contract Fee is Ownable { uint public constant BP_DENOMINATOR = 10000; mapping(uint16 => FeeConfig) public chainIdToFeeBps; uint16 public defaultFeeBp; address public feeOwner; // defaults to owner struct FeeConfig { uint16 feeBP; bool enabled; } event SetFeeBp(uint16 dstchainId, bool enabled, uint16 feeBp); event SetDefaultFeeBp(uint16 feeBp); event SetFeeOwner(address feeOwner); constructor(){ feeOwner = owner(); } function setDefaultFeeBp(uint16 _feeBp) public virtual onlyOwner { require(_feeBp <= BP_DENOMINATOR, "Fee: fee bp must be <= BP_DENOMINATOR"); defaultFeeBp = _feeBp; emit SetDefaultFeeBp(defaultFeeBp); } function setFeeBp(uint16 _dstChainId, bool _enabled, uint16 _feeBp) public virtual onlyOwner { require(_feeBp <= BP_DENOMINATOR, "Fee: fee bp must be <= BP_DENOMINATOR"); chainIdToFeeBps[_dstChainId] = FeeConfig(_feeBp, _enabled); emit SetFeeBp(_dstChainId, _enabled, _feeBp); } function setFeeOwner(address _feeOwner) public virtual onlyOwner { require(_feeOwner != address(0x0), "Fee: feeOwner cannot be 0x"); feeOwner = _feeOwner; emit SetFeeOwner(_feeOwner); } function quoteOFTFee(uint16 _dstChainId, uint _amount) public virtual view returns (uint fee) { FeeConfig memory config = chainIdToFeeBps[_dstChainId]; if (config.enabled) { fee = _amount * config.feeBP / BP_DENOMINATOR; } else if (defaultFeeBp > 0) { fee = _amount * defaultFeeBp / BP_DENOMINATOR; } else { fee = 0; } } function _payOFTFee(address _from, uint16 _dstChainId, uint _amount) internal virtual returns (uint amount, uint fee) { fee = quoteOFTFee(_dstChainId, _amount); amount = _amount - fee; if (fee > 0) { _transferFrom(_from, feeOwner, fee); } } function _transferFrom(address _from, address _to, uint _amount) internal virtual returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./BaseOFTWithFee.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract ProxyOFTWithFee is BaseOFTWithFee { using SafeERC20 for IERC20; IERC20 internal immutable innerToken; uint internal immutable ld2sdRate; // total amount is transferred from this chain to other chains, ensuring the total is less than uint64.max in sd uint public outboundAmount; constructor(address _token, uint8 _sharedDecimals, address _lzEndpoint) BaseOFTWithFee(_sharedDecimals, _lzEndpoint) { innerToken = IERC20(_token); (bool success, bytes memory data) = _token.staticcall( abi.encodeWithSignature("decimals()") ); require(success, "ProxyOFTWithFee: failed to get token decimals"); uint8 decimals = abi.decode(data, (uint8)); require(_sharedDecimals <= decimals, "ProxyOFTWithFee: sharedDecimals must be <= decimals"); ld2sdRate = 10 ** (decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return innerToken.totalSupply() - outboundAmount; } function token() public view virtual override returns (address) { return address(innerToken); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom(address _from, uint16, bytes32, uint _amount) internal virtual override returns (uint) { require(_from == _msgSender(), "ProxyOFTWithFee: owner is not send caller"); _amount = _transferFrom(_from, address(this), _amount); // _amount still may have dust if the token has transfer fee, then give the dust back to the sender (uint amount, uint dust) = _removeDust(_amount); if (dust > 0) innerToken.safeTransfer(_from, dust); // check total outbound amount outboundAmount += amount; uint cap = _sd2ld(type(uint64).max); require(cap >= outboundAmount, "ProxyOFTWithFee: outboundAmount overflow"); return amount; } function _creditTo(uint16, address _toAddress, uint _amount) internal virtual override returns (uint) { outboundAmount -= _amount; // tokens are already in this contract, so no need to transfer if (_toAddress == address(this)) { return _amount; } return _transferFrom(address(this), _toAddress, _amount); } function _transferFrom(address _from, address _to, uint _amount) internal virtual override returns (uint) { uint before = innerToken.balanceOf(_to); if (_from == address(this)) { innerToken.safeTransfer(_to, _amount); } else { innerToken.safeTransferFrom(_from, _to, _amount); } return innerToken.balanceOf(_to) - before; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ 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 pragma solidity ^0.8.0; import "./BaseOFTV2.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract ProxyOFTV2 is BaseOFTV2 { using SafeERC20 for IERC20; IERC20 internal immutable innerToken; uint internal immutable ld2sdRate; // total amount is transferred from this chain to other chains, ensuring the total is less than uint64.max in sd uint public outboundAmount; constructor( address _token, uint8 _sharedDecimals, address _lzEndpoint ) BaseOFTV2(_sharedDecimals, _lzEndpoint) { innerToken = IERC20(_token); (bool success, bytes memory data) = _token.staticcall(abi.encodeWithSignature("decimals()")); require(success, "ProxyOFT: failed to get token decimals"); uint8 decimals = abi.decode(data, (uint8)); require(_sharedDecimals <= decimals, "ProxyOFT: sharedDecimals must be <= decimals"); ld2sdRate = 10**(decimals - _sharedDecimals); } /************************************************************************ * public functions ************************************************************************/ function circulatingSupply() public view virtual override returns (uint) { return innerToken.totalSupply() - outboundAmount; } function token() public view virtual override returns (address) { return address(innerToken); } /************************************************************************ * internal functions ************************************************************************/ function _debitFrom( address _from, uint16, bytes32, uint _amount ) internal virtual override returns (uint) { require(_from == _msgSender(), "ProxyOFT: owner is not send caller"); _amount = _transferFrom(_from, address(this), _amount); // _amount still may have dust if the token has transfer fee, then give the dust back to the sender (uint amount, uint dust) = _removeDust(_amount); if (dust > 0) innerToken.safeTransfer(_from, dust); // check total outbound amount outboundAmount += amount; uint cap = _sd2ld(type(uint64).max); require(cap >= outboundAmount, "ProxyOFT: outboundAmount overflow"); return amount; } function _creditTo( uint16, address _toAddress, uint _amount ) internal virtual override returns (uint) { outboundAmount -= _amount; // tokens are already in this contract, so no need to transfer if (_toAddress == address(this)) { return _amount; } return _transferFrom(address(this), _toAddress, _amount); } function _transferFrom( address _from, address _to, uint _amount ) internal virtual override returns (uint) { uint before = innerToken.balanceOf(_to); if (_from == address(this)) { innerToken.safeTransfer(_to, _amount); } else { innerToken.safeTransferFrom(_from, _to, _amount); } return innerToken.balanceOf(_to) - before; } function _ld2sdRate() internal view virtual override returns (uint) { return ld2sdRate; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "../interfaces/IOFTV2.sol"; import "../interfaces/IOFTReceiverV2.sol"; import "../../../../libraries/BytesLib.sol"; // OFTStakingMock is an example to integrate with OFT. It shows how to send OFT cross chain with a custom payload and // call a receiver contract on the destination chain when oft is received. contract OFTStakingMockV2 is IOFTReceiverV2 { using SafeERC20 for IERC20; using BytesLib for bytes; uint64 public constant DST_GAS_FOR_CALL = 300000; // estimate gas usage of onOFTReceived() // packet type uint8 public constant PT_DEPOSIT_TO_REMOTE_CHAIN = 1; // ... other types // variables IOFTV2 public oft; mapping(uint16 => bytes32) public remoteStakingContracts; mapping(address => uint) public balances; bool public paused; // for testing try/catch event Deposit(address from, uint amount); event Withdrawal(address to, uint amount); event DepositToDstChain(address from, uint16 dstChainId, bytes to, uint amountOut); // _oft can be any composable OFT contract, e.g. ComposableOFT, ComposableBasedOFT and ComposableProxyOFT. constructor(address _oft) { oft = IOFTV2(_oft); IERC20(oft.token()).safeApprove(_oft, type(uint).max); } function setRemoteStakingContract(uint16 _chainId, bytes32 _stakingContract) external { remoteStakingContracts[_chainId] = _stakingContract; } function deposit(uint _amount) external payable { IERC20(oft.token()).safeTransferFrom(msg.sender, address(this), _amount); balances[msg.sender] += _amount; emit Deposit(msg.sender, _amount); } function withdraw(uint _amount) external { withdrawTo(_amount, msg.sender); } function withdrawTo(uint _amount, address _to) public { require(balances[msg.sender] >= _amount); balances[msg.sender] -= _amount; IERC20(oft.token()).safeTransfer(_to, _amount); emit Withdrawal(msg.sender, _amount); } function depositToDstChain( uint16 _dstChainId, bytes calldata _to, // address of the owner of token on the destination chain uint _amount, // amount of token to deposit bytes calldata _adapterParams ) external payable { bytes32 dstStakingContract = remoteStakingContracts[_dstChainId]; require(dstStakingContract != bytes32(0), "invalid _dstChainId"); // transfer token from sender to this contract // if the oft is not the proxy oft, dont need to transfer token to this contract // and call sendAndCall() with the msg.sender (_from) instead of address(this) // here we use a common pattern to be compatible with all kinds of composable OFT IERC20(oft.token()).safeTransferFrom(msg.sender, address(this), _amount); bytes memory payload = abi.encode(PT_DEPOSIT_TO_REMOTE_CHAIN, _to); ICommonOFT.LzCallParams memory callParams = ICommonOFT.LzCallParams(payable(msg.sender), address(0), _adapterParams); oft.sendAndCall{value: msg.value}(address(this), _dstChainId, dstStakingContract, _amount, payload, DST_GAS_FOR_CALL, callParams); emit DepositToDstChain(msg.sender, _dstChainId, _to, _amount); } function quoteForDeposit( uint16 _dstChainId, bytes calldata _to, // address of the owner of token on the destination chain uint _amount, // amount of token to deposit bytes calldata _adapterParams ) public view returns (uint nativeFee, uint zroFee) { bytes32 dstStakingContract = remoteStakingContracts[_dstChainId]; require(dstStakingContract != bytes32(0), "invalid _dstChainId"); bytes memory payload = abi.encode(PT_DEPOSIT_TO_REMOTE_CHAIN, _to); return oft.estimateSendAndCallFee(_dstChainId, dstStakingContract, _amount, payload, DST_GAS_FOR_CALL, false, _adapterParams); } //----------------------------------------------------------------------------------------------------------------------- function onOFTReceived(uint16 _srcChainId, bytes calldata, uint64, bytes32 _from, uint _amount, bytes memory _payload) external override { require(!paused, "paused"); // for testing safe call require(msg.sender == address(oft), "only oft can call onOFTReceived()"); require(_from == remoteStakingContracts[_srcChainId], "invalid from"); uint8 pkType; assembly { pkType := mload(add(_payload, 32)) } if (pkType == PT_DEPOSIT_TO_REMOTE_CHAIN) { (, bytes memory toAddrBytes) = abi.decode(_payload, (uint8, bytes)); address to = toAddrBytes.toAddress(0); balances[to] += _amount; } else { revert("invalid deposit type"); } } function setPaused(bool _paused) external { paused = _paused; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; pragma abicoder v2; import "../interfaces/ILayerZeroReceiver.sol"; import "../interfaces/ILayerZeroEndpoint.sol"; import "../libs/LzLib.sol"; /* like a real LayerZero endpoint but can be mocked, which handle message transmission, verification, and receipt. - blocking: LayerZero provides ordered delivery of messages from a given sender to a destination chain. - non-reentrancy: endpoint has a non-reentrancy guard for both the send() and receive(), respectively. - adapter parameters: allows UAs to add arbitrary transaction params in the send() function, like airdrop on destination chain. unlike a real LayerZero endpoint, it is - no messaging library versioning - send() will short circuit to lzReceive() - no user application configuration */ contract LZEndpointMock is ILayerZeroEndpoint { uint8 internal constant _NOT_ENTERED = 1; uint8 internal constant _ENTERED = 2; mapping(address => address) public lzEndpointLookup; uint16 public mockChainId; bool public nextMsgBlocked; // fee config RelayerFeeConfig public relayerFeeConfig; ProtocolFeeConfig public protocolFeeConfig; uint public oracleFee; bytes public defaultAdapterParams; // path = remote addrss + local address // inboundNonce = [srcChainId][path]. mapping(uint16 => mapping(bytes => uint64)) public inboundNonce; //todo: this is a hack // outboundNonce = [dstChainId][srcAddress] mapping(uint16 => mapping(address => uint64)) public outboundNonce; // // outboundNonce = [dstChainId][path]. // mapping(uint16 => mapping(bytes => uint64)) public outboundNonce; // storedPayload = [srcChainId][path] mapping(uint16 => mapping(bytes => StoredPayload)) public storedPayload; // msgToDeliver = [srcChainId][path] mapping(uint16 => mapping(bytes => QueuedPayload[])) public msgsToDeliver; // reentrancy guard uint8 internal _send_entered_state = 1; uint8 internal _receive_entered_state = 1; struct ProtocolFeeConfig { uint zroFee; uint nativeBP; } struct RelayerFeeConfig { uint128 dstPriceRatio; // 10^10 uint128 dstGasPriceInWei; uint128 dstNativeAmtCap; uint64 baseGas; uint64 gasPerByte; } struct StoredPayload { uint64 payloadLength; address dstAddress; bytes32 payloadHash; } struct QueuedPayload { address dstAddress; uint64 nonce; bytes payload; } modifier sendNonReentrant() { require(_send_entered_state == _NOT_ENTERED, "LayerZeroMock: no send reentrancy"); _send_entered_state = _ENTERED; _; _send_entered_state = _NOT_ENTERED; } modifier receiveNonReentrant() { require(_receive_entered_state == _NOT_ENTERED, "LayerZeroMock: no receive reentrancy"); _receive_entered_state = _ENTERED; _; _receive_entered_state = _NOT_ENTERED; } event UaForceResumeReceive(uint16 chainId, bytes srcAddress); event PayloadCleared(uint16 srcChainId, bytes srcAddress, uint64 nonce, address dstAddress); event PayloadStored(uint16 srcChainId, bytes srcAddress, address dstAddress, uint64 nonce, bytes payload, bytes reason); event ValueTransferFailed(address indexed to, uint indexed quantity); constructor(uint16 _chainId) { mockChainId = _chainId; // init config relayerFeeConfig = RelayerFeeConfig({ dstPriceRatio: 1e10, // 1:1, same chain, same native coin dstGasPriceInWei: 1e10, dstNativeAmtCap: 1e19, baseGas: 100, gasPerByte: 1 }); protocolFeeConfig = ProtocolFeeConfig({zroFee: 1e18, nativeBP: 1000}); // BP 0.1 oracleFee = 1e16; defaultAdapterParams = LzLib.buildDefaultAdapterParams(200000); } // ------------------------------ ILayerZeroEndpoint Functions ------------------------------ function send( uint16 _chainId, bytes memory _path, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) external payable override sendNonReentrant { require(_path.length == 40, "LayerZeroMock: incorrect remote address size"); // only support evm chains address dstAddr; assembly { dstAddr := mload(add(_path, 20)) } address lzEndpoint = lzEndpointLookup[dstAddr]; require(lzEndpoint != address(0), "LayerZeroMock: destination LayerZero Endpoint not found"); // not handle zro token bytes memory adapterParams = _adapterParams.length > 0 ? _adapterParams : defaultAdapterParams; (uint nativeFee, ) = estimateFees(_chainId, msg.sender, _payload, _zroPaymentAddress != address(0x0), adapterParams); require(msg.value >= nativeFee, "LayerZeroMock: not enough native for fees"); uint64 nonce = ++outboundNonce[_chainId][msg.sender]; // refund if they send too much uint amount = msg.value - nativeFee; if (amount > 0) { (bool success, ) = _refundAddress.call{value: amount}(""); require(success, "LayerZeroMock: failed to refund"); } // Mock the process of receiving msg on dst chain // Mock the relayer paying the dstNativeAddr the amount of extra native token (, uint extraGas, uint dstNativeAmt, address payable dstNativeAddr) = LzLib.decodeAdapterParams(adapterParams); if (dstNativeAmt > 0) { (bool success, ) = dstNativeAddr.call{value: dstNativeAmt}(""); if (!success) { emit ValueTransferFailed(dstNativeAddr, dstNativeAmt); } } bytes memory srcUaAddress = abi.encodePacked(msg.sender, dstAddr); // cast this address to bytes bytes memory payload = _payload; LZEndpointMock(lzEndpoint).receivePayload(mockChainId, srcUaAddress, dstAddr, nonce, extraGas, payload); } function receivePayload( uint16 _srcChainId, bytes calldata _path, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload ) external override receiveNonReentrant { StoredPayload storage sp = storedPayload[_srcChainId][_path]; // assert and increment the nonce. no message shuffling require(_nonce == ++inboundNonce[_srcChainId][_path], "LayerZeroMock: wrong nonce"); // queue the following msgs inside of a stack to simulate a successful send on src, but not fully delivered on dst if (sp.payloadHash != bytes32(0)) { QueuedPayload[] storage msgs = msgsToDeliver[_srcChainId][_path]; QueuedPayload memory newMsg = QueuedPayload(_dstAddress, _nonce, _payload); // warning, might run into gas issues trying to forward through a bunch of queued msgs // shift all the msgs over so we can treat this like a fifo via array.pop() if (msgs.length > 0) { // extend the array msgs.push(newMsg); // shift all the indexes up for pop() for (uint i = 0; i < msgs.length - 1; i++) { msgs[i + 1] = msgs[i]; } // put the newMsg at the bottom of the stack msgs[0] = newMsg; } else { msgs.push(newMsg); } } else if (nextMsgBlocked) { storedPayload[_srcChainId][_path] = StoredPayload(uint64(_payload.length), _dstAddress, keccak256(_payload)); emit PayloadStored(_srcChainId, _path, _dstAddress, _nonce, _payload, bytes("")); // ensure the next msgs that go through are no longer blocked nextMsgBlocked = false; } else { try ILayerZeroReceiver(_dstAddress).lzReceive{gas: _gasLimit}(_srcChainId, _path, _nonce, _payload) {} catch (bytes memory reason) { storedPayload[_srcChainId][_path] = StoredPayload(uint64(_payload.length), _dstAddress, keccak256(_payload)); emit PayloadStored(_srcChainId, _path, _dstAddress, _nonce, _payload, reason); // ensure the next msgs that go through are no longer blocked nextMsgBlocked = false; } } } function getInboundNonce(uint16 _chainID, bytes calldata _path) external view override returns (uint64) { return inboundNonce[_chainID][_path]; } function getOutboundNonce(uint16 _chainID, address _srcAddress) external view override returns (uint64) { return outboundNonce[_chainID][_srcAddress]; } function estimateFees( uint16 _dstChainId, address _userApplication, bytes memory _payload, bool _payInZRO, bytes memory _adapterParams ) public view override returns (uint nativeFee, uint zroFee) { bytes memory adapterParams = _adapterParams.length > 0 ? _adapterParams : defaultAdapterParams; // Relayer Fee uint relayerFee = _getRelayerFee(_dstChainId, 1, _userApplication, _payload.length, adapterParams); // LayerZero Fee uint protocolFee = _getProtocolFees(_payInZRO, relayerFee, oracleFee); _payInZRO ? zroFee = protocolFee : nativeFee = protocolFee; // return the sum of fees nativeFee = nativeFee + relayerFee + oracleFee; } function getChainId() external view override returns (uint16) { return mockChainId; } function retryPayload( uint16 _srcChainId, bytes calldata _path, bytes calldata _payload ) external override { StoredPayload storage sp = storedPayload[_srcChainId][_path]; require(sp.payloadHash != bytes32(0), "LayerZeroMock: no stored payload"); require(_payload.length == sp.payloadLength && keccak256(_payload) == sp.payloadHash, "LayerZeroMock: invalid payload"); address dstAddress = sp.dstAddress; // empty the storedPayload sp.payloadLength = 0; sp.dstAddress = address(0); sp.payloadHash = bytes32(0); uint64 nonce = inboundNonce[_srcChainId][_path]; ILayerZeroReceiver(dstAddress).lzReceive(_srcChainId, _path, nonce, _payload); emit PayloadCleared(_srcChainId, _path, nonce, dstAddress); } function hasStoredPayload(uint16 _srcChainId, bytes calldata _path) external view override returns (bool) { StoredPayload storage sp = storedPayload[_srcChainId][_path]; return sp.payloadHash != bytes32(0); } function getSendLibraryAddress(address) external view override returns (address) { return address(this); } function getReceiveLibraryAddress(address) external view override returns (address) { return address(this); } function isSendingPayload() external view override returns (bool) { return _send_entered_state == _ENTERED; } function isReceivingPayload() external view override returns (bool) { return _receive_entered_state == _ENTERED; } function getConfig( uint16, /*_version*/ uint16, /*_chainId*/ address, /*_ua*/ uint /*_configType*/ ) external pure override returns (bytes memory) { return ""; } function getSendVersion( address /*_userApplication*/ ) external pure override returns (uint16) { return 1; } function getReceiveVersion( address /*_userApplication*/ ) external pure override returns (uint16) { return 1; } function setConfig( uint16, /*_version*/ uint16, /*_chainId*/ uint, /*_configType*/ bytes memory /*_config*/ ) external override {} function setSendVersion( uint16 /*version*/ ) external override {} function setReceiveVersion( uint16 /*version*/ ) external override {} function forceResumeReceive(uint16 _srcChainId, bytes calldata _path) external override { StoredPayload storage sp = storedPayload[_srcChainId][_path]; // revert if no messages are cached. safeguard malicious UA behaviour require(sp.payloadHash != bytes32(0), "LayerZeroMock: no stored payload"); require(sp.dstAddress == msg.sender, "LayerZeroMock: invalid caller"); // empty the storedPayload sp.payloadLength = 0; sp.dstAddress = address(0); sp.payloadHash = bytes32(0); emit UaForceResumeReceive(_srcChainId, _path); // resume the receiving of msgs after we force clear the "stuck" msg _clearMsgQue(_srcChainId, _path); } // ------------------------------ Other Public/External Functions -------------------------------------------------- function getLengthOfQueue(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint) { return msgsToDeliver[_srcChainId][_srcAddress].length; } // used to simulate messages received get stored as a payload function blockNextMsg() external { nextMsgBlocked = true; } function setDestLzEndpoint(address destAddr, address lzEndpointAddr) external { lzEndpointLookup[destAddr] = lzEndpointAddr; } function setRelayerPrice( uint128 _dstPriceRatio, uint128 _dstGasPriceInWei, uint128 _dstNativeAmtCap, uint64 _baseGas, uint64 _gasPerByte ) external { relayerFeeConfig.dstPriceRatio = _dstPriceRatio; relayerFeeConfig.dstGasPriceInWei = _dstGasPriceInWei; relayerFeeConfig.dstNativeAmtCap = _dstNativeAmtCap; relayerFeeConfig.baseGas = _baseGas; relayerFeeConfig.gasPerByte = _gasPerByte; } function setProtocolFee(uint _zroFee, uint _nativeBP) external { protocolFeeConfig.zroFee = _zroFee; protocolFeeConfig.nativeBP = _nativeBP; } function setOracleFee(uint _oracleFee) external { oracleFee = _oracleFee; } function setDefaultAdapterParams(bytes memory _adapterParams) external { defaultAdapterParams = _adapterParams; } // --------------------- Internal Functions --------------------- // simulates the relayer pushing through the rest of the msgs that got delayed due to the stored payload function _clearMsgQue(uint16 _srcChainId, bytes calldata _path) internal { QueuedPayload[] storage msgs = msgsToDeliver[_srcChainId][_path]; // warning, might run into gas issues trying to forward through a bunch of queued msgs while (msgs.length > 0) { QueuedPayload memory payload = msgs[msgs.length - 1]; ILayerZeroReceiver(payload.dstAddress).lzReceive(_srcChainId, _path, payload.nonce, payload.payload); msgs.pop(); } } function _getProtocolFees( bool _payInZro, uint _relayerFee, uint _oracleFee ) internal view returns (uint) { if (_payInZro) { return protocolFeeConfig.zroFee; } else { return ((_relayerFee + _oracleFee) * protocolFeeConfig.nativeBP) / 10000; } } function _getRelayerFee( uint16, /* _dstChainId */ uint16, /* _outboundProofType */ address, /* _userApplication */ uint _payloadSize, bytes memory _adapterParams ) internal view returns (uint) { (uint16 txType, uint extraGas, uint dstNativeAmt, ) = LzLib.decodeAdapterParams(_adapterParams); uint totalRemoteToken; // = baseGas + extraGas + requiredNativeAmount if (txType == 2) { require(relayerFeeConfig.dstNativeAmtCap >= dstNativeAmt, "LayerZeroMock: dstNativeAmt too large "); totalRemoteToken += dstNativeAmt; } // remoteGasTotal = dstGasPriceInWei * (baseGas + extraGas) uint remoteGasTotal = relayerFeeConfig.dstGasPriceInWei * (relayerFeeConfig.baseGas + extraGas); totalRemoteToken += remoteGasTotal; // tokenConversionRate = dstPrice / localPrice // basePrice = totalRemoteToken * tokenConversionRate uint basePrice = (totalRemoteToken * relayerFeeConfig.dstPriceRatio) / 10**10; // pricePerByte = (dstGasPriceInWei * gasPerBytes) * tokenConversionRate uint pricePerByte = (relayerFeeConfig.dstGasPriceInWei * relayerFeeConfig.gasPerByte * relayerFeeConfig.dstPriceRatio) / 10**10; return basePrice + _payloadSize * pricePerByte; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.6.0; pragma experimental ABIEncoderV2; library LzLib { // LayerZero communication struct CallParams { address payable refundAddress; address zroPaymentAddress; } //--------------------------------------------------------------------------- // Address type handling struct AirdropParams { uint airdropAmount; bytes32 airdropAddress; } function buildAdapterParams(LzLib.AirdropParams memory _airdropParams, uint _uaGasLimit) internal pure returns (bytes memory adapterParams) { if (_airdropParams.airdropAmount == 0 && _airdropParams.airdropAddress == bytes32(0x0)) { adapterParams = buildDefaultAdapterParams(_uaGasLimit); } else { adapterParams = buildAirdropAdapterParams(_uaGasLimit, _airdropParams); } } // Build Adapter Params function buildDefaultAdapterParams(uint _uaGas) internal pure returns (bytes memory) { // txType 1 // bytes [2 32 ] // fields [txType extraGas] return abi.encodePacked(uint16(1), _uaGas); } function buildAirdropAdapterParams(uint _uaGas, AirdropParams memory _params) internal pure returns (bytes memory) { require(_params.airdropAmount > 0, "Airdrop amount must be greater than 0"); require(_params.airdropAddress != bytes32(0x0), "Airdrop address must be set"); // txType 2 // bytes [2 32 32 bytes[] ] // fields [txType extraGas dstNativeAmt dstNativeAddress] return abi.encodePacked(uint16(2), _uaGas, _params.airdropAmount, _params.airdropAddress); } function getGasLimit(bytes memory _adapterParams) internal pure returns (uint gasLimit) { require(_adapterParams.length == 34 || _adapterParams.length > 66, "Invalid adapterParams"); assembly { gasLimit := mload(add(_adapterParams, 34)) } } // Decode Adapter Params function decodeAdapterParams(bytes memory _adapterParams) internal pure returns ( uint16 txType, uint uaGas, uint airdropAmount, address payable airdropAddress ) { require(_adapterParams.length == 34 || _adapterParams.length > 66, "Invalid adapterParams"); assembly { txType := mload(add(_adapterParams, 2)) uaGas := mload(add(_adapterParams, 34)) } require(txType == 1 || txType == 2, "Unsupported txType"); require(uaGas > 0, "Gas too low"); if (txType == 2) { assembly { airdropAmount := mload(add(_adapterParams, 66)) airdropAddress := mload(add(_adapterParams, 86)) } } } //--------------------------------------------------------------------------- // Address type handling function bytes32ToAddress(bytes32 _bytes32Address) internal pure returns (address _address) { return address(uint160(uint(_bytes32Address))); } function addressToBytes32(address _address) internal pure returns (bytes32 _bytes32Address) { return bytes32(uint(uint160(_address))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "./IOFTCore.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @dev Interface of the OFT standard */ interface IOFT is IOFTCore, IERC20 { }
// SPDX-License-Identifier: MIT pragma solidity >=0.5.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * @dev Interface of the IOFT core standard */ interface IOFTCore is IERC165 { /** * @dev estimate send token `_tokenId` to (`_dstChainId`, `_toAddress`) * _dstChainId - L0 defined chain id to send tokens too * _toAddress - dynamic bytes array which contains the address to whom you are sending tokens to on the dstChain * _amount - amount of the tokens to transfer * _useZro - indicates to use zro to pay L0 fees * _adapterParam - flexible bytes array to indicate messaging adapter services in L0 */ function estimateSendFee(uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams) external view returns (uint nativeFee, uint zroFee); /** * @dev send `_amount` amount of token to (`_dstChainId`, `_toAddress`) from `_from` * `_from` the owner of token * `_dstChainId` the destination chain identifier * `_toAddress` can be any size depending on the `dstChainId`. * `_amount` the quantity of tokens in wei * `_refundAddress` the address LayerZero refunds if too much message fee is sent * `_zroPaymentAddress` set to address(0x0) if not paying in ZRO (LayerZero Token) * `_adapterParams` is a flexible bytes array to indicate messaging adapter services */ function sendFrom(address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable; /** * @dev returns the circulating amount of tokens on current chain */ function circulatingSupply() external view returns (uint); /** * @dev returns the address of the ERC20 token */ function token() external view returns (address); /** * @dev Emitted when `_amount` tokens are moved from the `_sender` to (`_dstChainId`, `_toAddress`) * `_nonce` is the outbound nonce */ event SendToChain(uint16 indexed _dstChainId, address indexed _from, bytes _toAddress, uint _amount); /** * @dev Emitted when `_amount` tokens are received from `_srcChainId` into the `_toAddress` on the local chain. * `_nonce` is the inbound nonce. */ event ReceiveFromChain(uint16 indexed _srcChainId, address indexed _to, uint _amount); event SetUseCustomAdapterParams(bool _useCustomAdapterParams); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "./interfaces/IOFT.sol"; import "./OFTCore.sol"; // override decimal() function is needed contract OFT is OFTCore, ERC20, IOFT { constructor( string memory _name, string memory _symbol, address _lzEndpoint ) ERC20(_name, _symbol) OFTCore(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(OFTCore, IERC165) returns (bool) { return interfaceId == type(IOFT).interfaceId || interfaceId == type(IERC20).interfaceId || super.supportsInterface(interfaceId); } function token() public view virtual override returns (address) { return address(this); } function circulatingSupply() public view virtual override returns (uint) { return totalSupply(); } function _debitFrom( address _from, uint16, bytes memory, uint _amount ) internal virtual override returns (uint) { address spender = _msgSender(); if (_from != spender) _spendAllowance(_from, spender, _amount); _burn(_from, _amount); return _amount; } function _creditTo( uint16, address _toAddress, uint _amount ) internal virtual override returns (uint) { _mint(_toAddress, _amount); return _amount; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../../lzApp/NonblockingLzApp.sol"; import "./interfaces/IOFTCore.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; abstract contract OFTCore is NonblockingLzApp, ERC165, IOFTCore { using BytesLib for bytes; uint public constant NO_EXTRA_GAS = 0; // packet type uint16 public constant PT_SEND = 0; bool public useCustomAdapterParams; constructor(address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {} function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IOFTCore).interfaceId || super.supportsInterface(interfaceId); } function estimateSendFee( uint16 _dstChainId, bytes calldata _toAddress, uint _amount, bool _useZro, bytes calldata _adapterParams ) public view virtual override returns (uint nativeFee, uint zroFee) { // mock the payload for sendFrom() bytes memory payload = abi.encode(PT_SEND, _toAddress, _amount); return lzEndpoint.estimateFees(_dstChainId, address(this), payload, _useZro, _adapterParams); } function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); } function setUseCustomAdapterParams(bool _useCustomAdapterParams) public virtual onlyOwner { useCustomAdapterParams = _useCustomAdapterParams; emit SetUseCustomAdapterParams(_useCustomAdapterParams); } function _nonblockingLzReceive( uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload ) internal virtual override { uint16 packetType; assembly { packetType := mload(add(_payload, 32)) } if (packetType == PT_SEND) { _sendAck(_srcChainId, _srcAddress, _nonce, _payload); } else { revert("OFTCore: unknown packet type"); } } function _send( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual { _checkAdapterParams(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); uint amount = _debitFrom(_from, _dstChainId, _toAddress, _amount); bytes memory lzPayload = abi.encode(PT_SEND, _toAddress, amount); _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, msg.value); emit SendToChain(_dstChainId, _from, _toAddress, amount); } function _sendAck( uint16 _srcChainId, bytes memory, uint64, bytes memory _payload ) internal virtual { (, bytes memory toAddressBytes, uint amount) = abi.decode(_payload, (uint16, bytes, uint)); address to = toAddressBytes.toAddress(0); amount = _creditTo(_srcChainId, to, amount); emit ReceiveFromChain(_srcChainId, to, amount); } function _checkAdapterParams( uint16 _dstChainId, uint16 _pkType, bytes memory _adapterParams, uint _extraGas ) internal virtual { if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, _pkType, _adapterParams, _extraGas); } else { require(_adapterParams.length == 0, "OFTCore: _adapterParams must be empty."); } } function _debitFrom( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount ) internal virtual returns (uint); function _creditTo( uint16 _srcChainId, address _toAddress, uint _amount ) internal virtual returns (uint); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./OFT.sol"; contract NativeOFT is OFT, ReentrancyGuard { event Deposit(address indexed _dst, uint _amount); event Withdrawal(address indexed _src, uint _amount); constructor( string memory _name, string memory _symbol, address _lzEndpoint ) OFT(_name, _symbol, _lzEndpoint) {} function sendFrom( address _from, uint16 _dstChainId, bytes calldata _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams ) public payable virtual override(OFTCore, IOFTCore) { _send(_from, _dstChainId, _toAddress, _amount, _refundAddress, _zroPaymentAddress, _adapterParams); } function _send( address _from, uint16 _dstChainId, bytes memory _toAddress, uint _amount, address payable _refundAddress, address _zroPaymentAddress, bytes memory _adapterParams ) internal virtual override(OFTCore) { uint messageFee = _debitFromNative(_from, _dstChainId, _toAddress, _amount); bytes memory lzPayload = abi.encode(PT_SEND, _toAddress, _amount); if (useCustomAdapterParams) { _checkGasLimit(_dstChainId, PT_SEND, _adapterParams, NO_EXTRA_GAS); } else { require(_adapterParams.length == 0, "NativeOFT: _adapterParams must be empty."); } _lzSend(_dstChainId, lzPayload, _refundAddress, _zroPaymentAddress, _adapterParams, messageFee); } function deposit() public payable { _mint(msg.sender, msg.value); emit Deposit(msg.sender, msg.value); } function withdraw(uint _amount) public nonReentrant { require(balanceOf(msg.sender) >= _amount, "NativeOFT: Insufficient balance."); _burn(msg.sender, _amount); (bool success, ) = msg.sender.call{value: _amount}(""); require(success, "NativeOFT: failed to unwrap"); emit Withdrawal(msg.sender, _amount); } function _debitFromNative( address _from, uint16, bytes memory, uint _amount ) internal returns (uint messageFee) { messageFee = msg.sender == _from ? _debitMsgSender(_amount) : _debitMsgFrom(_from, _amount); } function _debitMsgSender(uint _amount) internal returns (uint messageFee) { uint msgSenderBalance = balanceOf(msg.sender); if (msgSenderBalance < _amount) { require(msgSenderBalance + msg.value >= _amount, "NativeOFT: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgSenderBalance; _mint(address(msg.sender), mintAmount); // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _transfer(msg.sender, address(this), _amount); return messageFee; } function _debitMsgFrom(address _from, uint _amount) internal returns (uint messageFee) { uint msgFromBalance = balanceOf(_from); if (msgFromBalance < _amount) { require(msgFromBalance + msg.value >= _amount, "NativeOFT: Insufficient msg.value"); // user can cover difference with additional msg.value ie. wrapping uint mintAmount = _amount - msgFromBalance; _mint(address(msg.sender), mintAmount); // transfer the differential amount to the contract _transfer(msg.sender, address(this), mintAmount); // overwrite the _amount to take the rest of the balance from the _from address _amount = msgFromBalance; // update the messageFee to take out mintAmount messageFee = msg.value - mintAmount; } else { messageFee = msg.value; } _spendAllowance(_from, msg.sender, _amount); _transfer(_from, address(this), _amount); return messageFee; } function _creditTo( uint16, address _toAddress, uint _amount ) internal override(OFT) returns (uint) { _burn(address(this), _amount); (bool success, ) = _toAddress.call{value: _amount}(""); require(success, "NativeOFT: failed to _creditTo"); return _amount; } receive() external payable { deposit(); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./OFTCore.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract ProxyOFT is OFTCore { using SafeERC20 for IERC20; IERC20 internal immutable innerToken; constructor(address _lzEndpoint, address _token) OFTCore(_lzEndpoint) { innerToken = IERC20(_token); } function circulatingSupply() public view virtual override returns (uint) { unchecked { return innerToken.totalSupply() - innerToken.balanceOf(address(this)); } } function token() public view virtual override returns (address) { return address(innerToken); } function _debitFrom( address _from, uint16, bytes memory, uint _amount ) internal virtual override returns (uint) { require(_from == _msgSender(), "ProxyOFT: owner is not send caller"); uint before = innerToken.balanceOf(address(this)); innerToken.safeTransferFrom(_from, address(this), _amount); return innerToken.balanceOf(address(this)) - before; } function _creditTo( uint16, address _toAddress, uint _amount ) internal virtual override returns (uint) { uint before = innerToken.balanceOf(_toAddress); innerToken.safeTransfer(_toAddress, _amount); return innerToken.balanceOf(_toAddress) - before; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../OFT.sol"; // @dev example implementation inheriting a OFT contract OFTMock is OFT { constructor(address _layerZeroEndpoint) OFT("MockOFT", "OFT", _layerZeroEndpoint) {} // @dev WARNING public mint function, do not use this in production function mintTokens(address _to, uint256 _amount) external { _mint(_to, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../OFTV2.sol"; // @dev mock OFTV2 demonstrating how to inherit OFTV2 contract OFTV2Mock is OFTV2 { constructor(address _layerZeroEndpoint, uint _initialSupply, uint8 _sharedDecimals) OFTV2("ExampleOFT", "OFT", _sharedDecimals, _layerZeroEndpoint) { _mint(_msgSender(), _initialSupply); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; // this is a MOCK contract ERC20Mock is ERC20 { constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) {} function mint(address _to, uint _amount) public { _mint(_to, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; // for mock purposes only, no limit on minting functionality contract ERC1155Mock is ERC1155 { constructor(string memory uri_) ERC1155(uri_) {} function mint( address _to, uint _tokenId, uint _amount ) public { _mint(_to, _tokenId, _amount, ""); } function mintBatch( address _to, uint[] memory _tokenIds, uint[] memory _amounts ) public { _mintBatch(_to, _tokenIds, _amounts, ""); } function transfer( address _to, uint _tokenId, uint _amount ) public { _safeTransferFrom(msg.sender, _to, _tokenId, _amount, ""); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; // for mock purposes only, no limit on minting functionality contract ERC721Mock is ERC721 { constructor(string memory _name, string memory _symbol) ERC721(_name, _symbol) {} string public baseTokenURI; function mint(address to, uint tokenId) public { _safeMint(to, tokenId, ""); } function transfer(address to, uint tokenId) public { _safeTransfer(msg.sender, to, tokenId, ""); } function isApprovedOrOwner(address spender, uint tokenId) public view virtual returns (bool) { return _isApprovedOrOwner(spender, tokenId); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; import "../ONFT721.sol"; contract ONFT721Mock is ONFT721 { constructor( string memory _name, string memory _symbol, uint _minGasToStore, address _layerZeroEndpoint ) ONFT721(_name, _symbol, _minGasToStore, _layerZeroEndpoint) {} function mint(address _tokenOwner, uint _newId) external payable { _safeMint(_tokenOwner, _newId); } function rawOwnerOf(uint tokenId) public view returns (address) { if (_exists(tokenId)) { return ownerOf(tokenId); } return address(0); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.4; import "../ONFT721A.sol"; // DISCLAIMER: This contract can only be deployed on one chain when deployed and calling // setTrustedRemotes with remote contracts. This is due to the sequential way 721A mints tokenIds. // This contract must be the first minter of each token id contract ONFT721AMock is ONFT721A { constructor( string memory _name, string memory _symbol, uint _minGasToTransferAndStore, address _layerZeroEndpoint ) ONFT721A(_name, _symbol, _minGasToTransferAndStore, _layerZeroEndpoint) {} function mint(uint _amount) external payable { _safeMint(msg.sender, _amount, ""); } }
// SPDX-License-Identifier: MIT // // Note: You will need to fund each deployed contract with gas. // // PingPong sends a LayerZero message back and forth between chains // a predetermined number of times (or until it runs out of gas). // // Demonstrates: // 1. a recursive feature of calling send() from inside lzReceive() // 2. how to `estimateFees` for a send()'ing a LayerZero message // 3. the contract pays the message fee pragma solidity ^0.8.0; pragma abicoder v2; import "../lzApp/NonblockingLzApp.sol"; /// @title PingPong /// @notice Sends a LayerZero message back and forth between chains a predetermined number of times. contract PingPong is NonblockingLzApp { /// @dev event emitted every ping() to keep track of consecutive pings count event Ping(uint256 pingCount); /// @param _endpoint The LayerZero endpoint address. constructor(address _endpoint) NonblockingLzApp(_endpoint) {} /// @notice Pings the destination chain, along with the current number of pings sent. /// @param _dstChainId The destination chain ID. /// @param _totalPings The total number of pings to send. function ping( uint16 _dstChainId, uint256 _totalPings ) public { _ping(_dstChainId, 0, _totalPings); } /// @dev Internal function to ping the destination chain, along with the current number of pings sent. /// @param _dstChainId The destination chain ID. /// @param _pings The current ping count. /// @param _totalPings The total number of pings to send. function _ping( uint16 _dstChainId, uint256 _pings, uint256 _totalPings ) internal { require(address(this).balance > 0, "This contract ran out of money."); // encode the payload with the number of pings bytes memory payload = abi.encode(_pings, _totalPings); // encode the adapter parameters uint16 version = 1; uint256 gasForDestinationLzReceive = 350000; bytes memory adapterParams = abi.encodePacked(version, gasForDestinationLzReceive); // send LayerZero message _lzSend( // {value: messageFee} will be paid out of this contract! _dstChainId, // destination chainId payload, // abi.encode()'ed bytes payable(this), // (msg.sender will be this contract) refund address (LayerZero will refund any extra gas back to caller of send()) address(0x0), // future param, unused for this example adapterParams, // v1 adapterParams, specify custom destination gas qty address(this).balance ); } /// @dev Internal function to handle incoming Ping messages. /// @param _srcChainId The source chain ID from which the message originated. /// @param _payload The payload of the incoming message. function _nonblockingLzReceive( uint16 _srcChainId, bytes memory, /*_srcAddress*/ uint64, /*_nonce*/ bytes memory _payload ) internal override { // decode the number of pings sent thus far (uint256 pingCount, uint256 totalPings) = abi.decode(_payload, (uint256, uint256)); ++pingCount; emit Ping(pingCount); // *pong* back to the other side if (pingCount < totalPings) { _ping(_srcChainId, pingCount, totalPings); } } // allow this contract to receive ether receive() external payable {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; pragma abicoder v2; import "../lzApp/NonblockingLzApp.sol"; /// @title A LayerZero example sending a cross chain message from a source chain to a destination chain to increment a counter contract OmniCounter is NonblockingLzApp { bytes public constant PAYLOAD = "\x01\x02\x03\x04"; uint public counter; constructor(address _lzEndpoint) NonblockingLzApp(_lzEndpoint) {} function _nonblockingLzReceive( uint16, bytes memory, uint64, bytes memory ) internal override { counter += 1; } function estimateFee( uint16 _dstChainId, bool _useZro, bytes calldata _adapterParams ) public view returns (uint nativeFee, uint zroFee) { return lzEndpoint.estimateFees(_dstChainId, address(this), PAYLOAD, _useZro, _adapterParams); } function incrementCounter(uint16 _dstChainId) public payable { _lzSend(_dstChainId, PAYLOAD, payable(msg.sender), address(0x0), bytes(""), msg.value); } function setOracle(uint16 dstChainId, address oracle) external onlyOwner { uint TYPE_ORACLE = 6; // set the Oracle lzEndpoint.setConfig(lzEndpoint.getSendVersion(address(this)), dstChainId, TYPE_ORACLE, abi.encode(oracle)); } function getOracle(uint16 remoteChainId) external view returns (address _oracle) { bytes memory bytesOracle = lzEndpoint.getConfig(lzEndpoint.getSendVersion(address(this)), remoteChainId, address(this), 6); assembly { _oracle := mload(add(bytesOracle, 32)) } } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "metadata": { "useLiteralContent": true } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint8","name":"_sharedDecimals","type":"uint8"},{"internalType":"address","name":"_lzEndpoint","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"_nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"_hash","type":"bytes32"}],"name":"CallOFTReceivedSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"_nonce","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"_payload","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"_reason","type":"bytes"}],"name":"MessageFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_address","type":"address"}],"name":"NonContractAddress","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":true,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"ReceiveFromChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"_nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"_payloadHash","type":"bytes32"}],"name":"RetryMessageSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"bytes32","name":"_toAddress","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"SendToChain","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_type","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_minDstGas","type":"uint256"}],"name":"SetMinDstGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"precrime","type":"address"}],"name":"SetPrecrime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_path","type":"bytes"}],"name":"SetTrustedRemote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"SetTrustedRemoteAddress","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":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_PAYLOAD_SIZE_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NO_EXTRA_GAS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PT_SEND","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PT_SEND_AND_CALL","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes32","name":"_from","type":"bytes32"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_payload","type":"bytes"},{"internalType":"uint256","name":"_gasForCall","type":"uint256"}],"name":"callOnOFTReceived","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"circulatingSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"creditedPackets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes32","name":"_toAddress","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_payload","type":"bytes"},{"internalType":"uint64","name":"_dstGasForCall","type":"uint64"},{"internalType":"bool","name":"_useZro","type":"bool"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateSendAndCallFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes32","name":"_toAddress","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_useZro","type":"bool"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateSendFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"failedMessages","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"forceResumeReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"_configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"}],"name":"getTrustedRemoteAddress","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"}],"name":"isTrustedRemote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lzEndpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"uint16","name":"","type":"uint16"}],"name":"minDstGasLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"nonblockingLzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"payloadSizeLimitLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"precrime","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_srcChainId","type":"uint16"},{"internalType":"bytes","name":"_srcAddress","type":"bytes"},{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"bytes","name":"_payload","type":"bytes"}],"name":"retryMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes32","name":"_toAddress","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_payload","type":"bytes"},{"internalType":"uint64","name":"_dstGasForCall","type":"uint64"},{"components":[{"internalType":"address payable","name":"refundAddress","type":"address"},{"internalType":"address","name":"zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"internalType":"struct ICommonOFT.LzCallParams","name":"_callParams","type":"tuple"}],"name":"sendAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes32","name":"_toAddress","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"components":[{"internalType":"address payable","name":"refundAddress","type":"address"},{"internalType":"address","name":"zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"adapterParams","type":"bytes"}],"internalType":"struct ICommonOFT.LzCallParams","name":"_callParams","type":"tuple"}],"name":"sendFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"},{"internalType":"uint16","name":"_chainId","type":"uint16"},{"internalType":"uint256","name":"_configType","type":"uint256"},{"internalType":"bytes","name":"_config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint16","name":"_packetType","type":"uint16"},{"internalType":"uint256","name":"_minGas","type":"uint256"}],"name":"setMinDstGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"setPayloadSizeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_precrime","type":"address"}],"name":"setPrecrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setReceiveVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_version","type":"uint16"}],"name":"setSendVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"bytes","name":"_path","type":"bytes"}],"name":"setTrustedRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"setTrustedRemoteAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sharedDecimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","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":"amount","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":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60e06040523480156200001157600080fd5b50604051620046ec380380620046ec8339810160408190526200003491620002fa565b8383838381818080620000473362000132565b6001600160a01b0316608052505060ff1660a052505081516200007290600a90602085019062000187565b5080516200008890600b90602084019062000187565b50505060006200009d6200018260201b60201c565b90508060ff168360ff1611156200010a5760405162461bcd60e51b815260206004820152602760248201527f4f46543a20736861726564446563696d616c73206d757374206265203c3d20646044820152666563696d616c7360c81b606482015260840160405180910390fd5b620001168382620003b4565b6200012390600a620004d9565b60c052506200052e9350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b601290565b8280546200019590620004f1565b90600052602060002090601f016020900481019282620001b9576000855562000204565b82601f10620001d457805160ff191683800117855562000204565b8280016001018555821562000204579182015b8281111562000204578251825591602001919060010190620001e7565b506200021292915062000216565b5090565b5b8082111562000212576000815560010162000217565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200025557600080fd5b81516001600160401b03808211156200027257620002726200022d565b604051601f8301601f19908116603f011681019082821181831017156200029d576200029d6200022d565b81604052838152602092508683858801011115620002ba57600080fd5b600091505b83821015620002de5785820183015181830184015290820190620002bf565b83821115620002f05760008385830101525b9695505050505050565b600080600080608085870312156200031157600080fd5b84516001600160401b03808211156200032957600080fd5b620003378883890162000243565b955060208701519150808211156200034e57600080fd5b506200035d8782880162000243565b935050604085015160ff811681146200037557600080fd5b60608601519092506001600160a01b03811681146200039357600080fd5b939692955090935050565b634e487b7160e01b600052601160045260246000fd5b600060ff821660ff841680821015620003d157620003d16200039e565b90039392505050565b600181815b808511156200041b578160001904821115620003ff57620003ff6200039e565b808516156200040d57918102915b93841c9390800290620003df565b509250929050565b6000826200043457506001620004d3565b816200044357506000620004d3565b81600181146200045c5760028114620004675762000487565b6001915050620004d3565b60ff8411156200047b576200047b6200039e565b50506001821b620004d3565b5060208310610133831016604e8410600b8410161715620004ac575081810a620004d3565b620004b88383620003da565b8060001904821115620004cf57620004cf6200039e565b0290505b92915050565b6000620004ea60ff84168362000423565b9392505050565b600181811c908216806200050657607f821691505b602082108114156200052857634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05160c051614141620005ab6000396000818161262801528181612a7d0152612d5a0152600061060a0152600081816107e40152818161095a01528181610c7201528181610d3201528181610eef0152818161155601528181611a8f01528181611f93015281816124140152612c1101526141416000f3fe6080604052600436106102ad5760003560e01c8063857749b011610175578063b353aaa7116100dc578063df2a5b3b11610095578063eb8d72b71161006f578063eb8d72b7146108e4578063f2fde38b14610904578063f5ecbdbc14610924578063fc0c546a1461094457600080fd5b8063df2a5b3b1461088f578063e6a20ae6146108af578063eaffd49a146108c457600080fd5b8063b353aaa7146107d2578063baf3292d14610806578063c446183414610826578063cbed8b9c1461083c578063d1deba1f1461085c578063dd62ed3e1461086f57600080fd5b80639bdb98121161012e5780639bdb9812146106e05780639f38369a14610732578063a457c2d714610752578063a4c51df514610772578063a6c3d16514610792578063a9059cbb146107b257600080fd5b8063857749b0146105f85780638cfd8f5c1461062c5780638da5cb5b146106645780639358928b14610696578063950c8a74146106ab57806395d89b41146106cb57600080fd5b80633d8b38f61161021957806366ad5c8a116101d257806366ad5c8a14610547578063695ef6bf1461056757806370a082311461057a578063715018a6146105b05780637533d788146105c557806376203b48146105e557600080fd5b80633d8b38f6146104615780633f1f4fa41461048157806342d65a8d146104ae57806344770515146104ce5780634c42899a146104e35780635b8c41e6146104f857600080fd5b806310ddb1371161026b57806310ddb1371461038b57806318160ddd146103ab57806323b872dd146103ca578063313ce567146103ea578063365260b41461040c578063395093511461044157600080fd5b80621d3567146102b257806301ffc9a7146102d457806306fdde031461030957806307e0db171461032b578063095ea7b31461034b5780630df374831461036b575b600080fd5b3480156102be57600080fd5b506102d26102cd3660046133b4565b610957565b005b3480156102e057600080fd5b506102f46102ef366004613447565b610b88565b60405190151581526020015b60405180910390f35b34801561031557600080fd5b5061031e610bbf565b60405161030091906134c9565b34801561033757600080fd5b506102d26103463660046134dc565b610c51565b34801561035757600080fd5b506102f461036636600461350c565b610cda565b34801561037757600080fd5b506102d2610386366004613538565b610cf2565b34801561039757600080fd5b506102d26103a63660046134dc565b610d11565b3480156103b757600080fd5b506009545b604051908152602001610300565b3480156103d657600080fd5b506102f46103e5366004613554565b610d69565b3480156103f657600080fd5b5060125b60405160ff9091168152602001610300565b34801561041857600080fd5b5061042c6104273660046135a5565b610d8d565b60408051928352602083019190915201610300565b34801561044d57600080fd5b506102f461045c36600461350c565b610de2565b34801561046d57600080fd5b506102f461047c36600461360a565b610e04565b34801561048d57600080fd5b506103bc61049c3660046134dc565b60036020526000908152604090205481565b3480156104ba57600080fd5b506102d26104c936600461360a565b610ed0565b3480156104da57600080fd5b506103bc600081565b3480156104ef57600080fd5b506103fa600081565b34801561050457600080fd5b506103bc6105133660046136c9565b6005602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b34801561055357600080fd5b506102d26105623660046133b4565b610f56565b6102d2610575366004613781565b611032565b34801561058657600080fd5b506103bc6105953660046137f4565b6001600160a01b031660009081526007602052604090205490565b3480156105bc57600080fd5b506102d261109d565b3480156105d157600080fd5b5061031e6105e03660046134dc565b6110b1565b6102d26105f3366004613811565b61114b565b34801561060457600080fd5b506103fa7f000000000000000000000000000000000000000000000000000000000000000081565b34801561063857600080fd5b506103bc6106473660046138c3565b600260209081526000928352604080842090915290825290205481565b34801561067057600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610300565b3480156106a257600080fd5b506103bc6111fa565b3480156106b757600080fd5b5060045461067e906001600160a01b031681565b3480156106d757600080fd5b5061031e61120a565b3480156106ec57600080fd5b506102f46106fb3660046136c9565b6006602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205460ff1681565b34801561073e57600080fd5b5061031e61074d3660046134dc565b611219565b34801561075e57600080fd5b506102f461076d36600461350c565b611330565b34801561077e57600080fd5b5061042c61078d3660046138f6565b6113ab565b34801561079e57600080fd5b506102d26107ad36600461360a565b61143a565b3480156107be57600080fd5b506102f46107cd36600461350c565b6114cd565b3480156107de57600080fd5b5061067e7f000000000000000000000000000000000000000000000000000000000000000081565b34801561081257600080fd5b506102d26108213660046137f4565b6114db565b34801561083257600080fd5b506103bc61271081565b34801561084857600080fd5b506102d26108573660046139af565b611537565b6102d261086a3660046133b4565b6115c1565b34801561087b57600080fd5b506103bc61088a366004613a1d565b6117d7565b34801561089b57600080fd5b506102d26108aa366004613a56565b611802565b3480156108bb57600080fd5b506103fa600181565b3480156108d057600080fd5b506102d26108df366004613a92565b61186c565b3480156108f057600080fd5b506102d26108ff36600461360a565b61198b565b34801561091057600080fd5b506102d261091f3660046137f4565b6119e5565b34801561093057600080fd5b5061031e61093f366004613b5a565b611a5e565b34801561095057600080fd5b503061067e565b337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146109d45760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff8616600090815260016020526040812080546109f290613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1e90613ba7565b8015610a6b5780601f10610a4057610100808354040283529160200191610a6b565b820191906000526020600020905b815481529060010190602001808311610a4e57829003601f168201915b50505050509050805186869050148015610a86575060008151115b8015610aae575080516020820120604051610aa49088908890613bdc565b6040518091039020145b610b095760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b60648201526084016109cb565b610b7f8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250611b0f92505050565b50505050505050565b60006001600160e01b03198216631f7ecdf760e01b1480610bb957506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600a8054610bce90613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610bfa90613ba7565b8015610c475780601f10610c1c57610100808354040283529160200191610c47565b820191906000526020600020905b815481529060010190602001808311610c2a57829003601f168201915b5050505050905090565b610c59611b88565b6040516307e0db1760e01b815261ffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307e0db17906024015b600060405180830381600087803b158015610cbf57600080fd5b505af1158015610cd3573d6000803e3d6000fd5b5050505050565b600033610ce8818585611be2565b5060019392505050565b610cfa611b88565b61ffff909116600090815260036020526040902055565b610d19611b88565b6040516310ddb13760e01b815261ffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906310ddb13790602401610ca5565b600033610d77858285611d06565b610d82858585611d80565b506001949350505050565b600080610dd38888888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611f2b92505050565b91509150965096945050505050565b600033610ce8818585610df583836117d7565b610dff9190613c02565b611be2565b61ffff831660009081526001602052604081208054829190610e2590613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610e5190613ba7565b8015610e9e5780601f10610e7357610100808354040283529160200191610e9e565b820191906000526020600020905b815481529060010190602001808311610e8157829003601f168201915b505050505090508383604051610eb5929190613bdc565b60405180910390208180519060200120149150509392505050565b610ed8611b88565b6040516342d65a8d60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342d65a8d90610f2890869086908690600401613c43565b600060405180830381600087803b158015610f4257600080fd5b505af1158015610b7f573d6000803e3d6000fd5b333014610fb45760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b60648201526084016109cb565b61102a8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f89018190048102820181019092528781528993509150879087908190840183828082843760009201919091525061201f92505050565b505050505050565b61102a8585858561104660208701876137f4565b61105660408801602089016137f4565b6110636040890189613c61565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120a692505050565b6110a5611b88565b6110af600061218e565b565b600160205260009081526040902080546110ca90613ba7565b80601f01602080910402602001604051908101604052809291908181526020018280546110f690613ba7565b80156111435780601f1061111857610100808354040283529160200191611143565b820191906000526020600020905b81548152906001019060200180831161112657829003601f168201915b505050505081565b6111ef8888888888888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061119891505060208901896137f4565b6111a860408a0160208b016137f4565b6111b560408b018b613c61565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121de92505050565b505050505050505050565b600061120560095490565b905090565b6060600b8054610bce90613ba7565b61ffff811660009081526001602052604081208054606092919061123c90613ba7565b80601f016020809104026020016040519081016040528092919081815260200182805461126890613ba7565b80156112b55780601f1061128a576101008083540402835291602001916112b5565b820191906000526020600020905b81548152906001019060200180831161129857829003601f168201915b5050505050905080516000141561130e5760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f726400000060448201526064016109cb565b6113296000601483516113219190613ca7565b8391906122da565b9392505050565b6000338161133e82866117d7565b90508381101561139e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016109cb565b610d828286868403611be2565b6000806114288b8b8b8b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8d018190048102820181019092528b81528e93508d9250908c908c90819084018382808284376000920191909152506123e792505050565b91509150995099975050505050505050565b611442611b88565b81813060405160200161145793929190613cbe565b60408051601f1981840301815291815261ffff8516600090815260016020908152919020825161148c93919290910190613231565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8383836040516114c093929190613c43565b60405180910390a1505050565b600033610ce8818585611d80565b6114e3611b88565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b9060200160405180910390a150565b61153f611b88565b6040516332fb62e760e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063cbed8b9c906115939088908890889088908890600401613ce4565b600060405180830381600087803b1580156115ad57600080fd5b505af11580156111ef573d6000803e3d6000fd5b61ffff861660009081526005602052604080822090516115e49088908890613bdc565b90815260408051602092819003830190206001600160401b038716600090815292529020549050806116645760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b60648201526084016109cb565b808383604051611675929190613bdc565b6040518091039020146116d45760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b60648201526084016109cb565b61ffff871660009081526005602052604080822090516116f79089908990613bdc565b90815260408051602092819003830181206001600160401b038916600090815290845282902093909355601f8801829004820283018201905286825261178f918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061201f92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e587878787856040516117c6959493929190613d1d565b60405180910390a150505050505050565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b61180a611b88565b61ffff83811660008181526002602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016114c0565b3330146118bb5760405162461bcd60e51b815260206004820152601f60248201527f4f4654436f72653a2063616c6c6572206d757374206265204f4654436f72650060448201526064016109cb565b6118c63086866124a2565b9350846001600160a01b03168a61ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8660405161190891815260200190565b60405180910390a3604051633fe79aed60e11b81526001600160a01b03861690637fcf35da90839061194c908e908e908e908e908e908d908d908d90600401613d58565b600060405180830381600088803b15801561196657600080fd5b5087f115801561197a573d6000803e3d6000fd5b505050505050505050505050505050565b611993611b88565b61ffff831660009081526001602052604090206119b19083836132b5565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8383836040516114c093929190613c43565b6119ed611b88565b6001600160a01b038116611a525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109cb565b611a5b8161218e565b50565b604051633d7b2f6f60e21b815261ffff808616600483015284166024820152306044820152606481018290526060907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5ecbdbc90608401600060405180830381865afa158015611ade573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b069190810190613db3565b95945050505050565b600080611b725a60966366ad5c8a60e01b89898989604051602401611b379493929190613e20565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152309291906124f4565b915091508161102a5761102a868686868561257e565b6000546001600160a01b031633146110af5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109cb565b6001600160a01b038316611c445760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016109cb565b6001600160a01b038216611ca55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016109cb565b6001600160a01b0383811660008181526008602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000611d1284846117d7565b90506000198114611d7a5781811015611d6d5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016109cb565b611d7a8484848403611be2565b50505050565b6001600160a01b038316611de45760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016109cb565b6001600160a01b038216611e465760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016109cb565b6001600160a01b03831660009081526007602052604090205481811015611ebe5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016109cb565b6001600160a01b0380851660008181526007602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611f1e9086815260200190565b60405180910390a3611d7a565b6000806000611f7987611f3d88612620565b6040805160006020820152602181019390935260c09190911b6001600160c01b0319166041830152805160298184030181526049909201905290565b60405163040a7bb160e41b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340a7bb1090611fd0908b90309086908b908b90600401613e5e565b6040805180830381865afa158015611fec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120109190613eb2565b92509250509550959350505050565b600061202b82826126a6565b905060ff81166120465761204185858585612702565b610cd3565b60ff81166001141561205e5761204185858585612792565b60405162461bcd60e51b815260206004820152601c60248201527f4f4654436f72653a20756e6b6e6f776e207061636b657420747970650000000060448201526064016109cb565b60006120b4878284816129a0565b6120bd85612a75565b5090506120cc88888884612ab5565b90506000811161211a5760405162461bcd60e51b815260206004820152601960248201527813d19510dbdc994e88185b5bdd5b9d081d1bdbc81cdb585b1b603a1b60448201526064016109cb565b600061212987611f3d84612620565b9050612139888287878734612ae7565b86896001600160a01b03168961ffff167fd81fc9b8523134ed613870ed029d6170cbb73aa6a6bc311b9a642689fb9df59a8560405161217a91815260200190565b60405180910390a450979650505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006121f6896001846001600160401b0389166129a0565b6121ff87612a75565b50905061220e8a8a8a84612ab5565b90506000811161225c5760405162461bcd60e51b815260206004820152601960248201527813d19510dbdc994e88185b5bdd5b9d081d1bdbc81cdb585b1b603a1b60448201526064016109cb565b6000612273338a61226c85612620565b8a8a612c8d565b90506122838a8287878734612ae7565b888b6001600160a01b03168b61ffff167fd81fc9b8523134ed613870ed029d6170cbb73aa6a6bc311b9a642689fb9df59a856040516122c491815260200190565b60405180910390a4509998505050505050505050565b6060816122e881601f613c02565b10156123275760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016109cb565b6123318284613c02565b845110156123755760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016109cb565b60608215801561239457604051915060008252602082016040526123de565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156123cd5780518352602092830192016123b5565b5050858452601f01601f1916604052505b50949350505050565b60008060006123fa338a61226c8b612620565b60405163040a7bb160e41b81529091506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340a7bb1090612451908d90309086908b908b90600401613e5e565b6040805180830381865afa15801561246d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124919190613eb2565b925092505097509795505050505050565b600033306001600160a01b038616148015906124d05750806001600160a01b0316856001600160a01b031614155b156124e0576124e0858285611d06565b6124eb858585611d80565b50909392505050565b6000606060008060008661ffff166001600160401b038111156125195761251961365c565b6040519080825280601f01601f191660200182016040528015612543576020820181803683370190505b50905060008087516020890160008d8df191503d925086831115612565578692505b828152826000602083013e909890975095505050505050565b8180519060200120600560008761ffff1661ffff168152602001908152602001600020856040516125af9190613ed6565b9081526040805191829003602090810183206001600160401b0388166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061260c9087908790879087908790613ef2565b60405180910390a15050505050565b505050565b60008061264d7f000000000000000000000000000000000000000000000000000000000000000084613f5a565b90506001600160401b03811115610bb95760405162461bcd60e51b815260206004820152601a60248201527f4f4654436f72653a20616d6f756e745344206f766572666c6f7700000000000060448201526064016109cb565b60006126b3826001613c02565b835110156126f95760405162461bcd60e51b8152602060048201526013602482015272746f55696e74385f6f75744f66426f756e647360681b60448201526064016109cb565b50016001015190565b60008061270e83612cce565b90925090506001600160a01b0382166127275761dead91505b600061273282612d53565b905061273f878483612d88565b9050826001600160a01b03168761ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8360405161278191815260200190565b60405180910390a350505050505050565b60008060008060006127a386612d9b565b945094509450945094506000600660008b61ffff1661ffff168152602001908152602001600020896040516127d89190613ed6565b90815260408051602092819003830190206001600160401b038b166000908152925281205460ff16915061280b85612d53565b9050816128795761281d8b3083612d88565b61ffff8c16600090815260066020526040908190209051919250600191612845908d90613ed6565b90815260408051602092819003830190206001600160401b038d16600090815292529020805460ff19169115159190911790555b6001600160a01b0386163b6128d0576040516001600160a01b03871681527f9aedf5fdba8716db3b6705ca00150643309995d4f818a249ed6dde6677e7792d9060200160405180910390a150505050505050611d7a565b8a8a8a8a8a8a868a60008a6128ee578b6001600160401b03166128f0565b5a5b90506000806129225a609663eaffd49a60e01b8e8e8e8d8d8d8d8d604051602401611b37989796959493929190613f6e565b91509150811561297b578751602089012060405161ffff8d16907fb8890edbfc1c74692f527444645f95489c3703cc2df42e4a366f5d06fa6cd8849061296d908e908e908690613fe2565b60405180910390a250612988565b6129888b8b8b8b8561257e565b50505050505050505050505050505050505050505050565b60006129ab83612e52565b61ffff80871660009081526002602090815260408083209389168352929052205490915080612a1c5760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f742073657400000000000060448201526064016109cb565b612a268382613c02565b82101561102a5760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f77000000000060448201526064016109cb565b600080612aa27f000000000000000000000000000000000000000000000000000000000000000084614010565b9050612aae8184613ca7565b9150915091565b6000336001600160a01b0386168114612ad357612ad3868285611d06565b612add8684612eae565b5090949350505050565b61ffff861660009081526001602052604081208054612b0590613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054612b3190613ba7565b8015612b7e5780601f10612b5357610100808354040283529160200191612b7e565b820191906000526020600020905b815481529060010190602001808311612b6157829003601f168201915b50505050509050805160001415612bf05760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b60648201526084016109cb565b612bfb878751612fe2565b60405162c5803160e81b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c5803100908490612c52908b9086908c908c908c908c90600401614024565b6000604051808303818588803b158015612c6b57600080fd5b505af1158015612c7f573d6000803e3d6000fd5b505050505050505050505050565b6060600185856001600160a01b0389168587604051602001612cb49695949392919061408b565b604051602081830303815290604052905095945050505050565b60008080612cdc84826126a6565b60ff16148015612ced575082516029145b612d345760405162461bcd60e51b815260206004820152601860248201527713d19510dbdc994e881a5b9d985b1a59081c185e5b1bd85960421b60448201526064016109cb565b612d3f83600d613050565b9150612d4c8360216130b5565b9050915091565b6000610bb97f00000000000000000000000000000000000000000000000000000000000000006001600160401b0384166140ec565b6000612d948383613112565b5092915050565b600080806060816001612dae87836126a6565b60ff1614612df95760405162461bcd60e51b815260206004820152601860248201527713d19510dbdc994e881a5b9d985b1a59081c185e5b1bd85960421b60448201526064016109cb565b612e0486600d613050565b9350612e118660216130b5565b9250612e1e8660296131d3565b9450612e2b8660496130b5565b9050612e476051808851612e3f9190613ca7565b8891906122da565b915091939590929450565b6000602282511015612ea65760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d730000000060448201526064016109cb565b506022015190565b6001600160a01b038216612f0e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016109cb565b6001600160a01b03821660009081526007602052604090205481811015612f825760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016109cb565b6001600160a01b03831660008181526007602090815260408083208686039055600980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b61ffff82166000908152600360205260409020548061300057506127105b8082111561261b5760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c6172676560448201526064016109cb565b600061305d826014613c02565b835110156130a55760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016109cb565b500160200151600160601b900490565b60006130c2826008613c02565b835110156131095760405162461bcd60e51b8152602060048201526014602482015273746f55696e7436345f6f75744f66426f756e647360601b60448201526064016109cb565b50016008015190565b6001600160a01b0382166131685760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016109cb565b806009600082825461317a9190613c02565b90915550506001600160a01b0382166000818152600760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60006131e0826020613c02565b835110156132285760405162461bcd60e51b8152602060048201526015602482015274746f427974657333325f6f75744f66426f756e647360581b60448201526064016109cb565b50016020015190565b82805461323d90613ba7565b90600052602060002090601f01602090048101928261325f57600085556132a5565b82601f1061327857805160ff19168380011785556132a5565b828001600101855582156132a5579182015b828111156132a557825182559160200191906001019061328a565b506132b1929150613329565b5090565b8280546132c190613ba7565b90600052602060002090601f0160209004810192826132e357600085556132a5565b82601f106132fc5782800160ff198235161785556132a5565b828001600101855582156132a5579182015b828111156132a557823582559160200191906001019061330e565b5b808211156132b1576000815560010161332a565b803561ffff8116811461335057600080fd5b919050565b60008083601f84011261336757600080fd5b5081356001600160401b0381111561337e57600080fd5b60208301915083602082850101111561339657600080fd5b9250929050565b80356001600160401b038116811461335057600080fd5b600080600080600080608087890312156133cd57600080fd5b6133d68761333e565b955060208701356001600160401b03808211156133f257600080fd5b6133fe8a838b01613355565b909750955085915061341260408a0161339d565b9450606089013591508082111561342857600080fd5b5061343589828a01613355565b979a9699509497509295939492505050565b60006020828403121561345957600080fd5b81356001600160e01b03198116811461132957600080fd5b60005b8381101561348c578181015183820152602001613474565b83811115611d7a5750506000910152565b600081518084526134b5816020860160208601613471565b601f01601f19169290920160200192915050565b602081526000611329602083018461349d565b6000602082840312156134ee57600080fd5b6113298261333e565b6001600160a01b0381168114611a5b57600080fd5b6000806040838503121561351f57600080fd5b823561352a816134f7565b946020939093013593505050565b6000806040838503121561354b57600080fd5b61352a8361333e565b60008060006060848603121561356957600080fd5b8335613574816134f7565b92506020840135613584816134f7565b929592945050506040919091013590565b8035801515811461335057600080fd5b60008060008060008060a087890312156135be57600080fd5b6135c78761333e565b955060208701359450604087013593506135e360608801613595565b925060808701356001600160401b038111156135fe57600080fd5b61343589828a01613355565b60008060006040848603121561361f57600080fd5b6136288461333e565b925060208401356001600160401b0381111561364357600080fd5b61364f86828701613355565b9497909650939450505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561369a5761369a61365c565b604052919050565b60006001600160401b038211156136bb576136bb61365c565b50601f01601f191660200190565b6000806000606084860312156136de57600080fd5b6136e78461333e565b925060208401356001600160401b0381111561370257600080fd5b8401601f8101861361371357600080fd5b8035613726613721826136a2565b613672565b81815287602083850101111561373b57600080fd5b816020840160208301376000602083830101528094505050506137606040850161339d565b90509250925092565b60006060828403121561377b57600080fd5b50919050565b600080600080600060a0868803121561379957600080fd5b85356137a4816134f7565b94506137b26020870161333e565b9350604086013592506060860135915060808601356001600160401b038111156137db57600080fd5b6137e788828901613769565b9150509295509295909350565b60006020828403121561380657600080fd5b8135611329816134f7565b60008060008060008060008060e0898b03121561382d57600080fd5b8835613838816134f7565b975061384660208a0161333e565b9650604089013595506060890135945060808901356001600160401b038082111561387057600080fd5b61387c8c838d01613355565b909650945084915061389060a08c0161339d565b935060c08b01359150808211156138a657600080fd5b506138b38b828c01613769565b9150509295985092959890939650565b600080604083850312156138d657600080fd5b6138df8361333e565b91506138ed6020840161333e565b90509250929050565b600080600080600080600080600060e08a8c03121561391457600080fd5b61391d8a61333e565b985060208a0135975060408a0135965060608a01356001600160401b038082111561394757600080fd5b6139538d838e01613355565b909850965086915061396760808d0161339d565b955061397560a08d01613595565b945060c08c013591508082111561398b57600080fd5b506139988c828d01613355565b915080935050809150509295985092959850929598565b6000806000806000608086880312156139c757600080fd5b6139d08661333e565b94506139de6020870161333e565b93506040860135925060608601356001600160401b03811115613a0057600080fd5b613a0c88828901613355565b969995985093965092949392505050565b60008060408385031215613a3057600080fd5b8235613a3b816134f7565b91506020830135613a4b816134f7565b809150509250929050565b600080600060608486031215613a6b57600080fd5b613a748461333e565b9250613a826020850161333e565b9150604084013590509250925092565b6000806000806000806000806000806101008b8d031215613ab257600080fd5b613abb8b61333e565b995060208b01356001600160401b0380821115613ad757600080fd5b613ae38e838f01613355565b909b509950899150613af760408e0161339d565b985060608d0135975060808d01359150613b10826134f7565b90955060a08c0135945060c08c01359080821115613b2d57600080fd5b50613b3a8d828e01613355565b9150809450508092505060e08b013590509295989b9194979a5092959850565b60008060008060808587031215613b7057600080fd5b613b798561333e565b9350613b876020860161333e565b92506040850135613b97816134f7565b9396929550929360600135925050565b600181811c90821680613bbb57607f821691505b6020821081141561377b57634e487b7160e01b600052602260045260246000fd5b8183823760009101908152919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115613c1557613c15613bec565b500190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201526000611b06604083018486613c1a565b6000808335601e19843603018112613c7857600080fd5b8301803591506001600160401b03821115613c9257600080fd5b60200191503681900382131561339657600080fd5b600082821015613cb957613cb9613bec565b500390565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b600061ffff808816835280871660208401525084604083015260806060830152613d12608083018486613c1a565b979650505050505050565b61ffff86168152608060208201526000613d3b608083018688613c1a565b6001600160401b0394909416604083015250606001529392505050565b61ffff8916815260c060208201526000613d7660c08301898b613c1a565b6001600160401b038816604084015286606084015285608084015282810360a0840152613da4818587613c1a565b9b9a5050505050505050505050565b600060208284031215613dc557600080fd5b81516001600160401b03811115613ddb57600080fd5b8201601f81018413613dec57600080fd5b8051613dfa613721826136a2565b818152856020838501011115613e0f57600080fd5b611b06826020830160208601613471565b61ffff85168152608060208201526000613e3d608083018661349d565b6001600160401b03851660408401528281036060840152613d12818561349d565b61ffff861681526001600160a01b038516602082015260a060408201819052600090613e8c9083018661349d565b84151560608401528281036080840152613ea6818561349d565b98975050505050505050565b60008060408385031215613ec557600080fd5b505080516020909101519092909150565b60008251613ee8818460208701613471565b9190910192915050565b61ffff8616815260a060208201526000613f0f60a083018761349d565b6001600160401b03861660408401528281036060840152613f30818661349d565b90508281036080840152613ea6818561349d565b634e487b7160e01b600052601260045260246000fd5b600082613f6957613f69613f44565b500490565b600061010061ffff8b168352806020840152613f8c8184018b61349d565b6001600160401b038a166040850152606084018990526001600160a01b038816608085015260a0840187905283810360c08501529050613fcc818661349d565b9150508260e08301529998505050505050505050565b606081526000613ff5606083018661349d565b6001600160401b039490941660208301525060400152919050565b60008261401f5761401f613f44565b500690565b61ffff8716815260c06020820152600061404160c083018861349d565b8281036040840152614053818861349d565b6001600160a01b0387811660608601528616608085015283810360a0850152905061407e818561349d565b9998505050505050505050565b60ff60f81b8760f81b16815285600182015260006001600160401b0360c01b808760c01b166021840152856029840152808560c01b1660498401525082516140da816051850160208701613471565b91909101605101979650505050505050565b600081600019048311821515161561410657614106613bec565b50029056fea264697066735822122064b1bfa8d803624d4e8db89260d0346b3c75e1f4cc649a736fb49c521768f02164736f6c634300080c0033000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000120000000000000000000000003c2269811836af69497e5f486a85d7316753cf6200000000000000000000000000000000000000000000000000000000000000094f70656e4f6365616e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034f4f450000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106102ad5760003560e01c8063857749b011610175578063b353aaa7116100dc578063df2a5b3b11610095578063eb8d72b71161006f578063eb8d72b7146108e4578063f2fde38b14610904578063f5ecbdbc14610924578063fc0c546a1461094457600080fd5b8063df2a5b3b1461088f578063e6a20ae6146108af578063eaffd49a146108c457600080fd5b8063b353aaa7146107d2578063baf3292d14610806578063c446183414610826578063cbed8b9c1461083c578063d1deba1f1461085c578063dd62ed3e1461086f57600080fd5b80639bdb98121161012e5780639bdb9812146106e05780639f38369a14610732578063a457c2d714610752578063a4c51df514610772578063a6c3d16514610792578063a9059cbb146107b257600080fd5b8063857749b0146105f85780638cfd8f5c1461062c5780638da5cb5b146106645780639358928b14610696578063950c8a74146106ab57806395d89b41146106cb57600080fd5b80633d8b38f61161021957806366ad5c8a116101d257806366ad5c8a14610547578063695ef6bf1461056757806370a082311461057a578063715018a6146105b05780637533d788146105c557806376203b48146105e557600080fd5b80633d8b38f6146104615780633f1f4fa41461048157806342d65a8d146104ae57806344770515146104ce5780634c42899a146104e35780635b8c41e6146104f857600080fd5b806310ddb1371161026b57806310ddb1371461038b57806318160ddd146103ab57806323b872dd146103ca578063313ce567146103ea578063365260b41461040c578063395093511461044157600080fd5b80621d3567146102b257806301ffc9a7146102d457806306fdde031461030957806307e0db171461032b578063095ea7b31461034b5780630df374831461036b575b600080fd5b3480156102be57600080fd5b506102d26102cd3660046133b4565b610957565b005b3480156102e057600080fd5b506102f46102ef366004613447565b610b88565b60405190151581526020015b60405180910390f35b34801561031557600080fd5b5061031e610bbf565b60405161030091906134c9565b34801561033757600080fd5b506102d26103463660046134dc565b610c51565b34801561035757600080fd5b506102f461036636600461350c565b610cda565b34801561037757600080fd5b506102d2610386366004613538565b610cf2565b34801561039757600080fd5b506102d26103a63660046134dc565b610d11565b3480156103b757600080fd5b506009545b604051908152602001610300565b3480156103d657600080fd5b506102f46103e5366004613554565b610d69565b3480156103f657600080fd5b5060125b60405160ff9091168152602001610300565b34801561041857600080fd5b5061042c6104273660046135a5565b610d8d565b60408051928352602083019190915201610300565b34801561044d57600080fd5b506102f461045c36600461350c565b610de2565b34801561046d57600080fd5b506102f461047c36600461360a565b610e04565b34801561048d57600080fd5b506103bc61049c3660046134dc565b60036020526000908152604090205481565b3480156104ba57600080fd5b506102d26104c936600461360a565b610ed0565b3480156104da57600080fd5b506103bc600081565b3480156104ef57600080fd5b506103fa600081565b34801561050457600080fd5b506103bc6105133660046136c9565b6005602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205481565b34801561055357600080fd5b506102d26105623660046133b4565b610f56565b6102d2610575366004613781565b611032565b34801561058657600080fd5b506103bc6105953660046137f4565b6001600160a01b031660009081526007602052604090205490565b3480156105bc57600080fd5b506102d261109d565b3480156105d157600080fd5b5061031e6105e03660046134dc565b6110b1565b6102d26105f3366004613811565b61114b565b34801561060457600080fd5b506103fa7f000000000000000000000000000000000000000000000000000000000000001281565b34801561063857600080fd5b506103bc6106473660046138c3565b600260209081526000928352604080842090915290825290205481565b34801561067057600080fd5b506000546001600160a01b03165b6040516001600160a01b039091168152602001610300565b3480156106a257600080fd5b506103bc6111fa565b3480156106b757600080fd5b5060045461067e906001600160a01b031681565b3480156106d757600080fd5b5061031e61120a565b3480156106ec57600080fd5b506102f46106fb3660046136c9565b6006602090815260009384526040808520845180860184018051928152908401958401959095209452929052825290205460ff1681565b34801561073e57600080fd5b5061031e61074d3660046134dc565b611219565b34801561075e57600080fd5b506102f461076d36600461350c565b611330565b34801561077e57600080fd5b5061042c61078d3660046138f6565b6113ab565b34801561079e57600080fd5b506102d26107ad36600461360a565b61143a565b3480156107be57600080fd5b506102f46107cd36600461350c565b6114cd565b3480156107de57600080fd5b5061067e7f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf6281565b34801561081257600080fd5b506102d26108213660046137f4565b6114db565b34801561083257600080fd5b506103bc61271081565b34801561084857600080fd5b506102d26108573660046139af565b611537565b6102d261086a3660046133b4565b6115c1565b34801561087b57600080fd5b506103bc61088a366004613a1d565b6117d7565b34801561089b57600080fd5b506102d26108aa366004613a56565b611802565b3480156108bb57600080fd5b506103fa600181565b3480156108d057600080fd5b506102d26108df366004613a92565b61186c565b3480156108f057600080fd5b506102d26108ff36600461360a565b61198b565b34801561091057600080fd5b506102d261091f3660046137f4565b6119e5565b34801561093057600080fd5b5061031e61093f366004613b5a565b611a5e565b34801561095057600080fd5b503061067e565b337f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf626001600160a01b0316146109d45760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff8616600090815260016020526040812080546109f290613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1e90613ba7565b8015610a6b5780601f10610a4057610100808354040283529160200191610a6b565b820191906000526020600020905b815481529060010190602001808311610a4e57829003601f168201915b50505050509050805186869050148015610a86575060008151115b8015610aae575080516020820120604051610aa49088908890613bdc565b6040518091039020145b610b095760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b60648201526084016109cb565b610b7f8787878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8a018190048102820181019092528881528a935091508890889081908401838280828437600092019190915250611b0f92505050565b50505050505050565b60006001600160e01b03198216631f7ecdf760e01b1480610bb957506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600a8054610bce90613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610bfa90613ba7565b8015610c475780601f10610c1c57610100808354040283529160200191610c47565b820191906000526020600020905b815481529060010190602001808311610c2a57829003601f168201915b5050505050905090565b610c59611b88565b6040516307e0db1760e01b815261ffff821660048201527f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf626001600160a01b0316906307e0db17906024015b600060405180830381600087803b158015610cbf57600080fd5b505af1158015610cd3573d6000803e3d6000fd5b5050505050565b600033610ce8818585611be2565b5060019392505050565b610cfa611b88565b61ffff909116600090815260036020526040902055565b610d19611b88565b6040516310ddb13760e01b815261ffff821660048201527f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf626001600160a01b0316906310ddb13790602401610ca5565b600033610d77858285611d06565b610d82858585611d80565b506001949350505050565b600080610dd38888888888888080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611f2b92505050565b91509150965096945050505050565b600033610ce8818585610df583836117d7565b610dff9190613c02565b611be2565b61ffff831660009081526001602052604081208054829190610e2590613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054610e5190613ba7565b8015610e9e5780601f10610e7357610100808354040283529160200191610e9e565b820191906000526020600020905b815481529060010190602001808311610e8157829003601f168201915b505050505090508383604051610eb5929190613bdc565b60405180910390208180519060200120149150509392505050565b610ed8611b88565b6040516342d65a8d60e01b81526001600160a01b037f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf6216906342d65a8d90610f2890869086908690600401613c43565b600060405180830381600087803b158015610f4257600080fd5b505af1158015610b7f573d6000803e3d6000fd5b333014610fb45760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b60648201526084016109cb565b61102a8686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f89018190048102820181019092528781528993509150879087908190840183828082843760009201919091525061201f92505050565b505050505050565b61102a8585858561104660208701876137f4565b61105660408801602089016137f4565b6110636040890189613c61565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506120a692505050565b6110a5611b88565b6110af600061218e565b565b600160205260009081526040902080546110ca90613ba7565b80601f01602080910402602001604051908101604052809291908181526020018280546110f690613ba7565b80156111435780601f1061111857610100808354040283529160200191611143565b820191906000526020600020905b81548152906001019060200180831161112657829003601f168201915b505050505081565b6111ef8888888888888080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508a925061119891505060208901896137f4565b6111a860408a0160208b016137f4565b6111b560408b018b613c61565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506121de92505050565b505050505050505050565b600061120560095490565b905090565b6060600b8054610bce90613ba7565b61ffff811660009081526001602052604081208054606092919061123c90613ba7565b80601f016020809104026020016040519081016040528092919081815260200182805461126890613ba7565b80156112b55780601f1061128a576101008083540402835291602001916112b5565b820191906000526020600020905b81548152906001019060200180831161129857829003601f168201915b5050505050905080516000141561130e5760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f726400000060448201526064016109cb565b6113296000601483516113219190613ca7565b8391906122da565b9392505050565b6000338161133e82866117d7565b90508381101561139e5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016109cb565b610d828286868403611be2565b6000806114288b8b8b8b8b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8d018190048102820181019092528b81528e93508d9250908c908c90819084018382808284376000920191909152506123e792505050565b91509150995099975050505050505050565b611442611b88565b81813060405160200161145793929190613cbe565b60408051601f1981840301815291815261ffff8516600090815260016020908152919020825161148c93919290910190613231565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8383836040516114c093929190613c43565b60405180910390a1505050565b600033610ce8818585611d80565b6114e3611b88565b600480546001600160a01b0319166001600160a01b0383169081179091556040519081527f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b9060200160405180910390a150565b61153f611b88565b6040516332fb62e760e21b81526001600160a01b037f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf62169063cbed8b9c906115939088908890889088908890600401613ce4565b600060405180830381600087803b1580156115ad57600080fd5b505af11580156111ef573d6000803e3d6000fd5b61ffff861660009081526005602052604080822090516115e49088908890613bdc565b90815260408051602092819003830190206001600160401b038716600090815292529020549050806116645760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b60648201526084016109cb565b808383604051611675929190613bdc565b6040518091039020146116d45760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b60648201526084016109cb565b61ffff871660009081526005602052604080822090516116f79089908990613bdc565b90815260408051602092819003830181206001600160401b038916600090815290845282902093909355601f8801829004820283018201905286825261178f918991899089908190840183828082843760009201919091525050604080516020601f8a018190048102820181019092528881528a93509150889088908190840183828082843760009201919091525061201f92505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e587878787856040516117c6959493929190613d1d565b60405180910390a150505050505050565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205490565b61180a611b88565b61ffff83811660008181526002602090815260408083209487168084529482529182902085905581519283528201929092529081018290527f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016114c0565b3330146118bb5760405162461bcd60e51b815260206004820152601f60248201527f4f4654436f72653a2063616c6c6572206d757374206265204f4654436f72650060448201526064016109cb565b6118c63086866124a2565b9350846001600160a01b03168a61ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8660405161190891815260200190565b60405180910390a3604051633fe79aed60e11b81526001600160a01b03861690637fcf35da90839061194c908e908e908e908e908e908d908d908d90600401613d58565b600060405180830381600088803b15801561196657600080fd5b5087f115801561197a573d6000803e3d6000fd5b505050505050505050505050505050565b611993611b88565b61ffff831660009081526001602052604090206119b19083836132b5565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8383836040516114c093929190613c43565b6119ed611b88565b6001600160a01b038116611a525760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016109cb565b611a5b8161218e565b50565b604051633d7b2f6f60e21b815261ffff808616600483015284166024820152306044820152606481018290526060907f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf626001600160a01b03169063f5ecbdbc90608401600060405180830381865afa158015611ade573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b069190810190613db3565b95945050505050565b600080611b725a60966366ad5c8a60e01b89898989604051602401611b379493929190613e20565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152309291906124f4565b915091508161102a5761102a868686868561257e565b6000546001600160a01b031633146110af5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016109cb565b6001600160a01b038316611c445760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016109cb565b6001600160a01b038216611ca55760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016109cb565b6001600160a01b0383811660008181526008602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6000611d1284846117d7565b90506000198114611d7a5781811015611d6d5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e636500000060448201526064016109cb565b611d7a8484848403611be2565b50505050565b6001600160a01b038316611de45760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016109cb565b6001600160a01b038216611e465760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016109cb565b6001600160a01b03831660009081526007602052604090205481811015611ebe5760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016109cb565b6001600160a01b0380851660008181526007602052604080822086860390559286168082529083902080548601905591517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef90611f1e9086815260200190565b60405180910390a3611d7a565b6000806000611f7987611f3d88612620565b6040805160006020820152602181019390935260c09190911b6001600160c01b0319166041830152805160298184030181526049909201905290565b60405163040a7bb160e41b81529091506001600160a01b037f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf6216906340a7bb1090611fd0908b90309086908b908b90600401613e5e565b6040805180830381865afa158015611fec573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120109190613eb2565b92509250509550959350505050565b600061202b82826126a6565b905060ff81166120465761204185858585612702565b610cd3565b60ff81166001141561205e5761204185858585612792565b60405162461bcd60e51b815260206004820152601c60248201527f4f4654436f72653a20756e6b6e6f776e207061636b657420747970650000000060448201526064016109cb565b60006120b4878284816129a0565b6120bd85612a75565b5090506120cc88888884612ab5565b90506000811161211a5760405162461bcd60e51b815260206004820152601960248201527813d19510dbdc994e88185b5bdd5b9d081d1bdbc81cdb585b1b603a1b60448201526064016109cb565b600061212987611f3d84612620565b9050612139888287878734612ae7565b86896001600160a01b03168961ffff167fd81fc9b8523134ed613870ed029d6170cbb73aa6a6bc311b9a642689fb9df59a8560405161217a91815260200190565b60405180910390a450979650505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006121f6896001846001600160401b0389166129a0565b6121ff87612a75565b50905061220e8a8a8a84612ab5565b90506000811161225c5760405162461bcd60e51b815260206004820152601960248201527813d19510dbdc994e88185b5bdd5b9d081d1bdbc81cdb585b1b603a1b60448201526064016109cb565b6000612273338a61226c85612620565b8a8a612c8d565b90506122838a8287878734612ae7565b888b6001600160a01b03168b61ffff167fd81fc9b8523134ed613870ed029d6170cbb73aa6a6bc311b9a642689fb9df59a856040516122c491815260200190565b60405180910390a4509998505050505050505050565b6060816122e881601f613c02565b10156123275760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b60448201526064016109cb565b6123318284613c02565b845110156123755760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b60448201526064016109cb565b60608215801561239457604051915060008252602082016040526123de565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156123cd5780518352602092830192016123b5565b5050858452601f01601f1916604052505b50949350505050565b60008060006123fa338a61226c8b612620565b60405163040a7bb160e41b81529091506001600160a01b037f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf6216906340a7bb1090612451908d90309086908b908b90600401613e5e565b6040805180830381865afa15801561246d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124919190613eb2565b925092505097509795505050505050565b600033306001600160a01b038616148015906124d05750806001600160a01b0316856001600160a01b031614155b156124e0576124e0858285611d06565b6124eb858585611d80565b50909392505050565b6000606060008060008661ffff166001600160401b038111156125195761251961365c565b6040519080825280601f01601f191660200182016040528015612543576020820181803683370190505b50905060008087516020890160008d8df191503d925086831115612565578692505b828152826000602083013e909890975095505050505050565b8180519060200120600560008761ffff1661ffff168152602001908152602001600020856040516125af9190613ed6565b9081526040805191829003602090810183206001600160401b0388166000908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c9061260c9087908790879087908790613ef2565b60405180910390a15050505050565b505050565b60008061264d7f000000000000000000000000000000000000000000000000000000000000000184613f5a565b90506001600160401b03811115610bb95760405162461bcd60e51b815260206004820152601a60248201527f4f4654436f72653a20616d6f756e745344206f766572666c6f7700000000000060448201526064016109cb565b60006126b3826001613c02565b835110156126f95760405162461bcd60e51b8152602060048201526013602482015272746f55696e74385f6f75744f66426f756e647360681b60448201526064016109cb565b50016001015190565b60008061270e83612cce565b90925090506001600160a01b0382166127275761dead91505b600061273282612d53565b905061273f878483612d88565b9050826001600160a01b03168761ffff167fbf551ec93859b170f9b2141bd9298bf3f64322c6f7beb2543a0cb669834118bf8360405161278191815260200190565b60405180910390a350505050505050565b60008060008060006127a386612d9b565b945094509450945094506000600660008b61ffff1661ffff168152602001908152602001600020896040516127d89190613ed6565b90815260408051602092819003830190206001600160401b038b166000908152925281205460ff16915061280b85612d53565b9050816128795761281d8b3083612d88565b61ffff8c16600090815260066020526040908190209051919250600191612845908d90613ed6565b90815260408051602092819003830190206001600160401b038d16600090815292529020805460ff19169115159190911790555b6001600160a01b0386163b6128d0576040516001600160a01b03871681527f9aedf5fdba8716db3b6705ca00150643309995d4f818a249ed6dde6677e7792d9060200160405180910390a150505050505050611d7a565b8a8a8a8a8a8a868a60008a6128ee578b6001600160401b03166128f0565b5a5b90506000806129225a609663eaffd49a60e01b8e8e8e8d8d8d8d8d604051602401611b37989796959493929190613f6e565b91509150811561297b578751602089012060405161ffff8d16907fb8890edbfc1c74692f527444645f95489c3703cc2df42e4a366f5d06fa6cd8849061296d908e908e908690613fe2565b60405180910390a250612988565b6129888b8b8b8b8561257e565b50505050505050505050505050505050505050505050565b60006129ab83612e52565b61ffff80871660009081526002602090815260408083209389168352929052205490915080612a1c5760405162461bcd60e51b815260206004820152601a60248201527f4c7a4170703a206d696e4761734c696d6974206e6f742073657400000000000060448201526064016109cb565b612a268382613c02565b82101561102a5760405162461bcd60e51b815260206004820152601b60248201527f4c7a4170703a20676173206c696d697420697320746f6f206c6f77000000000060448201526064016109cb565b600080612aa27f000000000000000000000000000000000000000000000000000000000000000184614010565b9050612aae8184613ca7565b9150915091565b6000336001600160a01b0386168114612ad357612ad3868285611d06565b612add8684612eae565b5090949350505050565b61ffff861660009081526001602052604081208054612b0590613ba7565b80601f0160208091040260200160405190810160405280929190818152602001828054612b3190613ba7565b8015612b7e5780601f10612b5357610100808354040283529160200191612b7e565b820191906000526020600020905b815481529060010190602001808311612b6157829003601f168201915b50505050509050805160001415612bf05760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b60648201526084016109cb565b612bfb878751612fe2565b60405162c5803160e81b81526001600160a01b037f0000000000000000000000003c2269811836af69497e5f486a85d7316753cf62169063c5803100908490612c52908b9086908c908c908c908c90600401614024565b6000604051808303818588803b158015612c6b57600080fd5b505af1158015612c7f573d6000803e3d6000fd5b505050505050505050505050565b6060600185856001600160a01b0389168587604051602001612cb49695949392919061408b565b604051602081830303815290604052905095945050505050565b60008080612cdc84826126a6565b60ff16148015612ced575082516029145b612d345760405162461bcd60e51b815260206004820152601860248201527713d19510dbdc994e881a5b9d985b1a59081c185e5b1bd85960421b60448201526064016109cb565b612d3f83600d613050565b9150612d4c8360216130b5565b9050915091565b6000610bb97f00000000000000000000000000000000000000000000000000000000000000016001600160401b0384166140ec565b6000612d948383613112565b5092915050565b600080806060816001612dae87836126a6565b60ff1614612df95760405162461bcd60e51b815260206004820152601860248201527713d19510dbdc994e881a5b9d985b1a59081c185e5b1bd85960421b60448201526064016109cb565b612e0486600d613050565b9350612e118660216130b5565b9250612e1e8660296131d3565b9450612e2b8660496130b5565b9050612e476051808851612e3f9190613ca7565b8891906122da565b915091939590929450565b6000602282511015612ea65760405162461bcd60e51b815260206004820152601c60248201527f4c7a4170703a20696e76616c69642061646170746572506172616d730000000060448201526064016109cb565b506022015190565b6001600160a01b038216612f0e5760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016109cb565b6001600160a01b03821660009081526007602052604090205481811015612f825760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016109cb565b6001600160a01b03831660008181526007602090815260408083208686039055600980548790039055518581529192917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a3505050565b61ffff82166000908152600360205260409020548061300057506127105b8082111561261b5760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c6172676560448201526064016109cb565b600061305d826014613c02565b835110156130a55760405162461bcd60e51b8152602060048201526015602482015274746f416464726573735f6f75744f66426f756e647360581b60448201526064016109cb565b500160200151600160601b900490565b60006130c2826008613c02565b835110156131095760405162461bcd60e51b8152602060048201526014602482015273746f55696e7436345f6f75744f66426f756e647360601b60448201526064016109cb565b50016008015190565b6001600160a01b0382166131685760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016109cb565b806009600082825461317a9190613c02565b90915550506001600160a01b0382166000818152600760209081526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b60006131e0826020613c02565b835110156132285760405162461bcd60e51b8152602060048201526015602482015274746f427974657333325f6f75744f66426f756e647360581b60448201526064016109cb565b50016020015190565b82805461323d90613ba7565b90600052602060002090601f01602090048101928261325f57600085556132a5565b82601f1061327857805160ff19168380011785556132a5565b828001600101855582156132a5579182015b828111156132a557825182559160200191906001019061328a565b506132b1929150613329565b5090565b8280546132c190613ba7565b90600052602060002090601f0160209004810192826132e357600085556132a5565b82601f106132fc5782800160ff198235161785556132a5565b828001600101855582156132a5579182015b828111156132a557823582559160200191906001019061330e565b5b808211156132b1576000815560010161332a565b803561ffff8116811461335057600080fd5b919050565b60008083601f84011261336757600080fd5b5081356001600160401b0381111561337e57600080fd5b60208301915083602082850101111561339657600080fd5b9250929050565b80356001600160401b038116811461335057600080fd5b600080600080600080608087890312156133cd57600080fd5b6133d68761333e565b955060208701356001600160401b03808211156133f257600080fd5b6133fe8a838b01613355565b909750955085915061341260408a0161339d565b9450606089013591508082111561342857600080fd5b5061343589828a01613355565b979a9699509497509295939492505050565b60006020828403121561345957600080fd5b81356001600160e01b03198116811461132957600080fd5b60005b8381101561348c578181015183820152602001613474565b83811115611d7a5750506000910152565b600081518084526134b5816020860160208601613471565b601f01601f19169290920160200192915050565b602081526000611329602083018461349d565b6000602082840312156134ee57600080fd5b6113298261333e565b6001600160a01b0381168114611a5b57600080fd5b6000806040838503121561351f57600080fd5b823561352a816134f7565b946020939093013593505050565b6000806040838503121561354b57600080fd5b61352a8361333e565b60008060006060848603121561356957600080fd5b8335613574816134f7565b92506020840135613584816134f7565b929592945050506040919091013590565b8035801515811461335057600080fd5b60008060008060008060a087890312156135be57600080fd5b6135c78761333e565b955060208701359450604087013593506135e360608801613595565b925060808701356001600160401b038111156135fe57600080fd5b61343589828a01613355565b60008060006040848603121561361f57600080fd5b6136288461333e565b925060208401356001600160401b0381111561364357600080fd5b61364f86828701613355565b9497909650939450505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561369a5761369a61365c565b604052919050565b60006001600160401b038211156136bb576136bb61365c565b50601f01601f191660200190565b6000806000606084860312156136de57600080fd5b6136e78461333e565b925060208401356001600160401b0381111561370257600080fd5b8401601f8101861361371357600080fd5b8035613726613721826136a2565b613672565b81815287602083850101111561373b57600080fd5b816020840160208301376000602083830101528094505050506137606040850161339d565b90509250925092565b60006060828403121561377b57600080fd5b50919050565b600080600080600060a0868803121561379957600080fd5b85356137a4816134f7565b94506137b26020870161333e565b9350604086013592506060860135915060808601356001600160401b038111156137db57600080fd5b6137e788828901613769565b9150509295509295909350565b60006020828403121561380657600080fd5b8135611329816134f7565b60008060008060008060008060e0898b03121561382d57600080fd5b8835613838816134f7565b975061384660208a0161333e565b9650604089013595506060890135945060808901356001600160401b038082111561387057600080fd5b61387c8c838d01613355565b909650945084915061389060a08c0161339d565b935060c08b01359150808211156138a657600080fd5b506138b38b828c01613769565b9150509295985092959890939650565b600080604083850312156138d657600080fd5b6138df8361333e565b91506138ed6020840161333e565b90509250929050565b600080600080600080600080600060e08a8c03121561391457600080fd5b61391d8a61333e565b985060208a0135975060408a0135965060608a01356001600160401b038082111561394757600080fd5b6139538d838e01613355565b909850965086915061396760808d0161339d565b955061397560a08d01613595565b945060c08c013591508082111561398b57600080fd5b506139988c828d01613355565b915080935050809150509295985092959850929598565b6000806000806000608086880312156139c757600080fd5b6139d08661333e565b94506139de6020870161333e565b93506040860135925060608601356001600160401b03811115613a0057600080fd5b613a0c88828901613355565b969995985093965092949392505050565b60008060408385031215613a3057600080fd5b8235613a3b816134f7565b91506020830135613a4b816134f7565b809150509250929050565b600080600060608486031215613a6b57600080fd5b613a748461333e565b9250613a826020850161333e565b9150604084013590509250925092565b6000806000806000806000806000806101008b8d031215613ab257600080fd5b613abb8b61333e565b995060208b01356001600160401b0380821115613ad757600080fd5b613ae38e838f01613355565b909b509950899150613af760408e0161339d565b985060608d0135975060808d01359150613b10826134f7565b90955060a08c0135945060c08c01359080821115613b2d57600080fd5b50613b3a8d828e01613355565b9150809450508092505060e08b013590509295989b9194979a5092959850565b60008060008060808587031215613b7057600080fd5b613b798561333e565b9350613b876020860161333e565b92506040850135613b97816134f7565b9396929550929360600135925050565b600181811c90821680613bbb57607f821691505b6020821081141561377b57634e487b7160e01b600052602260045260246000fd5b8183823760009101908152919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115613c1557613c15613bec565b500190565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201526000611b06604083018486613c1a565b6000808335601e19843603018112613c7857600080fd5b8301803591506001600160401b03821115613c9257600080fd5b60200191503681900382131561339657600080fd5b600082821015613cb957613cb9613bec565b500390565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b600061ffff808816835280871660208401525084604083015260806060830152613d12608083018486613c1a565b979650505050505050565b61ffff86168152608060208201526000613d3b608083018688613c1a565b6001600160401b0394909416604083015250606001529392505050565b61ffff8916815260c060208201526000613d7660c08301898b613c1a565b6001600160401b038816604084015286606084015285608084015282810360a0840152613da4818587613c1a565b9b9a5050505050505050505050565b600060208284031215613dc557600080fd5b81516001600160401b03811115613ddb57600080fd5b8201601f81018413613dec57600080fd5b8051613dfa613721826136a2565b818152856020838501011115613e0f57600080fd5b611b06826020830160208601613471565b61ffff85168152608060208201526000613e3d608083018661349d565b6001600160401b03851660408401528281036060840152613d12818561349d565b61ffff861681526001600160a01b038516602082015260a060408201819052600090613e8c9083018661349d565b84151560608401528281036080840152613ea6818561349d565b98975050505050505050565b60008060408385031215613ec557600080fd5b505080516020909101519092909150565b60008251613ee8818460208701613471565b9190910192915050565b61ffff8616815260a060208201526000613f0f60a083018761349d565b6001600160401b03861660408401528281036060840152613f30818661349d565b90508281036080840152613ea6818561349d565b634e487b7160e01b600052601260045260246000fd5b600082613f6957613f69613f44565b500490565b600061010061ffff8b168352806020840152613f8c8184018b61349d565b6001600160401b038a166040850152606084018990526001600160a01b038816608085015260a0840187905283810360c08501529050613fcc818661349d565b9150508260e08301529998505050505050505050565b606081526000613ff5606083018661349d565b6001600160401b039490941660208301525060400152919050565b60008261401f5761401f613f44565b500690565b61ffff8716815260c06020820152600061404160c083018861349d565b8281036040840152614053818861349d565b6001600160a01b0387811660608601528616608085015283810360a0850152905061407e818561349d565b9998505050505050505050565b60ff60f81b8760f81b16815285600182015260006001600160401b0360c01b808760c01b166021840152856029840152808560c01b1660498401525082516140da816051850160208701613471565b91909101605101979650505050505050565b600081600019048311821515161561410657614106613bec565b50029056fea264697066735822122064b1bfa8d803624d4e8db89260d0346b3c75e1f4cc649a736fb49c521768f02164736f6c634300080c0033
Deployed Bytecode Sourcemap
141:2115:46:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1256:825:28;;;;;;;;;;-1:-1:-1;1256:825:28;;;;;:::i;:::-;;:::i;:::-;;1644:211:43;;;;;;;;;;-1:-1:-1;1644:211:43;;;;;:::i;:::-;;:::i;:::-;;;2029:14:76;;2022:22;2004:41;;1992:2;1977:18;1644:211:43;;;;;;;;2158:98:6;;;;;;;;;;;;;:::i;:::-;;;;;;;:::i;4791:121:28:-;;;;;;;;;;-1:-1:-1;4791:121:28;;;;;:::i;:::-;;:::i;4444:197:6:-;;;;;;;;;;-1:-1:-1;4444:197:6;;;;;:::i;:::-;;:::i;6649:140:28:-;;;;;;;;;;-1:-1:-1;6649:140:28;;;;;:::i;:::-;;:::i;4918:127::-;;;;;;;;;;-1:-1:-1;4918:127:28;;;;;:::i;:::-;;:::i;3255:106:6:-;;;;;;;;;;-1:-1:-1;3342:12:6;;3255:106;;;3855:25:76;;;3843:2;3828:18;3255:106:6;3709:177:76;5203:256:6;;;;;;;;;;-1:-1:-1;5203:256:6;;;;;:::i;:::-;;:::i;3104:91::-;;;;;;;;;;-1:-1:-1;3186:2:6;3104:91;;;4524:4:76;4512:17;;;4494:36;;4482:2;4467:18;3104:91:6;4352:184:76;1861:336:43;;;;;;;;;;-1:-1:-1;1861:336:43;;;;;:::i;:::-;;:::i;:::-;;;;5572:25:76;;;5628:2;5613:18;;5606:34;;;;5545:18;1861:336:43;5398:248:76;5854:234:6;;;;;;;;;;-1:-1:-1;5854:234:6;;;;;:::i;:::-;;:::i;6884:247:28:-;;;;;;;;;;-1:-1:-1;6884:247:28;;;;;:::i;:::-;;:::i;810:53::-;;;;;;;;;;-1:-1:-1;810:53:28;;;;;:::i;:::-;;;;;;;;;;;;;;5051:176;;;;;;;;;;-1:-1:-1;5051:176:28;;;;;:::i;:::-;;:::i;366:37:45:-;;;;;;;;;;;;402:1;366:37;;429:33;;;;;;;;;;;;461:1;429:33;;622:85:29;;;;;;;;;;-1:-1:-1;622:85:29;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1912:380;;;;;;;;;;-1:-1:-1;1912:380:29;;;;;:::i;:::-;;:::i;532:348:43:-;;;;;;:::i;:::-;;:::i;3419:125:6:-;;;;;;;;;;-1:-1:-1;3419:125:6;;;;;:::i;:::-;-1:-1:-1;;;;;3519:18:6;3493:7;3519:18;;;:9;:18;;;;;;;3419:125;1824:101:0;;;;;;;;;;;;;:::i;682:51:28:-;;;;;;;;;;-1:-1:-1;682:51:28;;;;;:::i;:::-;;:::i;886:566:43:-;;;;;;:::i;:::-;;:::i;517:37:45:-;;;;;;;;;;;;;;;739:65:28;;;;;;;;;;-1:-1:-1;739:65:28;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;1201:85:0;;;;;;;;;;-1:-1:-1;1247:7:0;1273:6;-1:-1:-1;;;;;1273:6:0;1201:85;;;-1:-1:-1;;;;;10623:32:76;;;10605:51;;10593:2;10578:18;1201:85:0;10459:203:76;796:110:46;;;;;;;;;;;;;:::i;869:23:28:-;;;;;;;;;;-1:-1:-1;869:23:28;;;;-1:-1:-1;;;;;869:23:28;;;2369:102:6;;;;;;;;;;;;;:::i;561:83:45:-;;;;;;;;;;-1:-1:-1;561:83:45;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5864:326:28;;;;;;;;;;-1:-1:-1;5864:326:28;;;;;:::i;:::-;;:::i;6575:427:6:-;;;;;;;;;;-1:-1:-1;6575:427:6;;;;;:::i;:::-;;:::i;2203:440:43:-;;;;;;;;;;-1:-1:-1;2203:440:43;;;;;:::i;:::-;;:::i;5580:278:28:-;;;;;;;;;;-1:-1:-1;5580:278:28;;;;;:::i;:::-;;:::i;3740:189:6:-;;;;;;;;;;-1:-1:-1;3740:189:6;;;;;:::i;:::-;;:::i;630:46:28:-;;;;;;;;;;;;;;;6196:133;;;;;;;;;;-1:-1:-1;6196:133:28;;;;;:::i;:::-;;:::i;568:55::-;;;;;;;;;;;;618:5;568:55;;4545:240;;;;;;;;;;-1:-1:-1;4545:240:28;;;;;:::i;:::-;;:::i;2511:795:29:-;;;;;;:::i;:::-;;:::i;3987:149:6:-;;;;;;;;;;-1:-1:-1;3987:149:6;;;;;:::i;:::-;;:::i;6335:255:28:-;;;;;;;;;;-1:-1:-1;6335:255:28;;;;;:::i;:::-;;:::i;468:42:45:-;;;;;;;;;;;;509:1;468:42;;1739:625;;;;;;;;;;-1:-1:-1;1739:625:45;;;;;:::i;:::-;;:::i;5370:204:28:-;;;;;;;;;;-1:-1:-1;5370:204:28;;;;;:::i;:::-;;:::i;2074:198:0:-;;;;;;;;;;-1:-1:-1;2074:198:0;;;;;:::i;:::-;;:::i;4239:247:28:-;;;;;;;;;;-1:-1:-1;4239:247:28;;;;;:::i;:::-;;:::i;912:101:46:-;;;;;;;;;;-1:-1:-1;1001:4:46;912:101;;1256:825:28;719:10:16;1532::28;-1:-1:-1;;;;;1508:35:28;;1500:78;;;;-1:-1:-1;;;1500:78:28;;15202:2:76;1500:78:28;;;15184:21:76;15241:2;15221:18;;;15214:30;15280:32;15260:18;;;15253:60;15330:18;;1500:78:28;;;;;;;;;1618:32;;;1589:26;1618:32;;;:19;:32;;;;;1589:61;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1835:13;:20;1813:11;;:18;;:42;:70;;;;;1882:1;1859:13;:20;:24;1813:70;:124;;;;-1:-1:-1;1913:24:28;;;;;;1887:22;;;;1897:11;;;;1887:22;:::i;:::-;;;;;;;;:50;1813:124;1792:209;;;;-1:-1:-1;;;1792:209:28;;16222:2:76;1792:209:28;;;16204:21:76;16261:2;16241:18;;;16234:30;16300:34;16280:18;;;16273:62;-1:-1:-1;;;16351:18:76;;;16344:36;16397:19;;1792:209:28;16020:402:76;1792:209:28;2012:62;2031:11;2044;;2012:62;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2012:62:28;;;;;;;;;;;;;;;;;;;;;;2057:6;;-1:-1:-1;2012:62:28;-1:-1:-1;2065:8:28;;;;;;2012:62;;2065:8;;;;2012:62;;;;;;;;;-1:-1:-1;2012:18:28;;-1:-1:-1;;;2012:62:28:i;:::-;1425:656;1256:825;;;;;;:::o;1644:211:43:-;1746:4;-1:-1:-1;;;;;;1769:39:43;;-1:-1:-1;;;1769:39:43;;:79;;-1:-1:-1;;;;;;;;;;937:40:18;;;1812:36:43;1762:86;1644:211;-1:-1:-1;;1644:211:43:o;2158:98:6:-;2212:13;2244:5;2237:12;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2158:98;:::o;4791:121:28:-;1094:13:0;:11;:13::i;:::-;4870:35:28::1;::::0;-1:-1:-1;;;4870:35:28;;16601:6:76;16589:19;;4870:35:28::1;::::0;::::1;16571:38:76::0;4870:10:28::1;-1:-1:-1::0;;;;;4870:25:28::1;::::0;::::1;::::0;16544:18:76;;4870:35:28::1;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;4791:121:::0;:::o;4444:197:6:-;4527:4;719:10:16;4581:32:6;719:10:16;4597:7:6;4606:6;4581:8;:32::i;:::-;-1:-1:-1;4630:4:6;;4444:197;-1:-1:-1;;;4444:197:6:o;6649:140:28:-;1094:13:0;:11;:13::i;:::-;6739:35:28::1;::::0;;::::1;;::::0;;;:22:::1;:35;::::0;;;;:43;6649:140::o;4918:127::-;1094:13:0;:11;:13::i;:::-;5000:38:28::1;::::0;-1:-1:-1;;;5000:38:28;;16601:6:76;16589:19;;5000:38:28::1;::::0;::::1;16571::76::0;5000:10:28::1;-1:-1:-1::0;;;;;5000:28:28::1;::::0;::::1;::::0;16544:18:76;;5000:38:28::1;16427:188:76::0;5203:256:6;5300:4;719:10:16;5356:38:6;5372:4;719:10:16;5387:6:6;5356:15;:38::i;:::-;5404:27;5414:4;5420:2;5424:6;5404:9;:27::i;:::-;-1:-1:-1;5448:4:6;;5203:256;-1:-1:-1;;;;5203:256:6:o;1861:336:43:-;2069:14;2085:11;2115:75;2132:11;2145:10;2157:7;2166;2175:14;;2115:75;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;2115:16:43;;-1:-1:-1;;;2115:75:43:i;:::-;2108:82;;;;1861:336;;;;;;;;;:::o;5854:234:6:-;5942:4;719:10:16;5996:64:6;719:10:16;6012:7:6;6049:10;6021:25;719:10:16;6012:7:6;6021:9;:25::i;:::-;:38;;;;:::i;:::-;5996:8;:64::i;6884:247:28:-;7025:32;;;6980:4;7025:32;;;:19;:32;;;;;6996:61;;6980:4;;7025:32;6996:61;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7112:11;;7102:22;;;;;;;:::i;:::-;;;;;;;;7084:13;7074:24;;;;;;:50;7067:57;;;6884:247;;;;;:::o;5051:176::-;1094:13:0;:11;:13::i;:::-;5165:55:28::1;::::0;-1:-1:-1;;;5165:55:28;;-1:-1:-1;;;;;5165:10:28::1;:29;::::0;::::1;::::0;:55:::1;::::0;5195:11;;5208;;;;5165:55:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;1912:380:29::0;719:10:16;2162:4:29;2138:29;2130:80;;;;-1:-1:-1;;;2130:80:29;;17689:2:76;2130:80:29;;;17671:21:76;17728:2;17708:18;;;17701:30;17767:34;17747:18;;;17740:62;-1:-1:-1;;;17818:18:76;;;17811:36;17864:19;;2130:80:29;17487:402:76;2130:80:29;2220:65;2242:11;2255;;2220:65;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2220:65:29;;;;;;;;;;;;;;;;;;;;;;2268:6;;-1:-1:-1;2220:65:29;-1:-1:-1;2276:8:29;;;;;;2220:65;;2276:8;;;;2220:65;;;;;;;;;-1:-1:-1;2220:21:29;;-1:-1:-1;;;2220:65:29:i;:::-;1912:380;;;;;;:::o;532:348:43:-;742:131;748:5;755:11;768:10;780:7;789:25;;;;:11;:25;:::i;:::-;816:29;;;;;;;;:::i;:::-;847:25;;;;:11;:25;:::i;:::-;742:131;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;742:5:43;;-1:-1:-1;;;742:131:43:i;1824:101:0:-;1094:13;:11;:13::i;:::-;1888:30:::1;1915:1;1888:18;:30::i;:::-;1824:101::o:0;682:51:28:-;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;886:566:43:-;1163:282;1189:5;1208:11;1233:10;1257:7;1278:8;;1163:282;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1300:14:43;;-1:-1:-1;1328:25:43;;-1:-1:-1;;1328:25:43;;;:11;:25;:::i;:::-;1367:29;;;;;;;;:::i;:::-;1410:25;;;;:11;:25;:::i;:::-;1163:282;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1163:12:43;;-1:-1:-1;;;1163:282:43:i;:::-;;886:566;;;;;;;;:::o;796:110:46:-;863:4;886:13;3342:12:6;;;3255:106;886:13:46;879:20;;796:110;:::o;2369:102:6:-;2425:13;2457:7;2450:14;;;;;:::i;5864:326:28:-;5987:35;;;5967:17;5987:35;;;:19;:35;;;;;5967:55;;5943:12;;5967:17;5987:35;5967:55;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6040:4;:11;6055:1;6040:16;;6032:58;;;;-1:-1:-1;;;6032:58:28;;18882:2:76;6032:58:28;;;18864:21:76;18921:2;18901:18;;;18894:30;18960:31;18940:18;;;18933:59;19009:18;;6032:58:28;18680:353:76;6032:58:28;6107:31;6118:1;6135:2;6121:4;:11;:16;;;;:::i;:::-;6107:4;;:31;:10;:31::i;:::-;6100:38;5864:326;-1:-1:-1;;;5864:326:28:o;6575:427:6:-;6668:4;719:10:16;6668:4:6;6749:25;719:10:16;6766:7:6;6749:9;:25::i;:::-;6722:52;;6812:15;6792:16;:35;;6784:85;;;;-1:-1:-1;;;6784:85:6;;19370:2:76;6784:85:6;;;19352:21:76;19409:2;19389:18;;;19382:30;19448:34;19428:18;;;19421:62;-1:-1:-1;;;19499:18:76;;;19492:35;19544:19;;6784:85:6;19168:401:76;6784:85:6;6903:60;6912:5;6919:7;6947:15;6928:16;:34;6903:8;:60::i;2203:440:43:-;2482:14;2498:11;2528:108;2552:11;2565:10;2577:7;2586:8;;2528:108;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;2528:108:43;;;;;;;;;;;;;;;;;;;;;;2596:14;;-1:-1:-1;2612:7:43;;-1:-1:-1;2528:108:43;2621:14;;;;;;2528:108;;2621:14;;;;2528:108;;;;;;;;;-1:-1:-1;2528:23:43;;-1:-1:-1;;;2528:108:43:i;:::-;2521:115;;;;2203:440;;;;;;;;;;;;:::o;5580:278:28:-;1094:13:0;:11;:13::i;:::-;5751:14:28::1;;5775:4;5734:47;;;;;;;;;;:::i;:::-;;::::0;;-1:-1:-1;;5734:47:28;;::::1;::::0;;;;;;5696:35:::1;::::0;::::1;;::::0;;;:19:::1;5734:47;5696:35:::0;;;;;;:85;;::::1;::::0;:35;;:85;;::::1;::::0;::::1;:::i;:::-;;5796:55;5820:14;5836;;5796:55;;;;;;;;:::i;:::-;;;;;;;;5580:278:::0;;;:::o;3740:189:6:-;3819:4;719:10:16;3873:28:6;719:10:16;3890:2:6;3894:6;3873:9;:28::i;6196:133:28:-;1094:13:0;:11;:13::i;:::-;6265:8:28::1;:20:::0;;-1:-1:-1;;;;;;6265:20:28::1;-1:-1:-1::0;;;;;6265:20:28;::::1;::::0;;::::1;::::0;;;6300:22:::1;::::0;10605:51:76;;;6300:22:28::1;::::0;10593:2:76;10578:18;6300:22:28::1;;;;;;;6196:133:::0;:::o;4545:240::-;1094:13:0;:11;:13::i;:::-;4716:62:28::1;::::0;-1:-1:-1;;;4716:62:28;;-1:-1:-1;;;;;4716:10:28::1;:20;::::0;::::1;::::0;:62:::1;::::0;4737:8;;4747;;4757:11;;4770:7;;;;4716:62:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;2511:795:29::0;2758:27;;;2736:19;2758:27;;;:14;:27;;;;;;:40;;;;2786:11;;;;2758:40;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;2758:48:29;;;;;;;;;;;;-1:-1:-1;2758:48:29;2816:73;;;;-1:-1:-1;;;2816:73:29;;20666:2:76;2816:73:29;;;20648:21:76;20705:2;20685:18;;;20678:30;20744:34;20724:18;;;20717:62;-1:-1:-1;;;20795:18:76;;;20788:33;20838:19;;2816:73:29;20464:399:76;2816:73:29;2930:11;2917:8;;2907:19;;;;;;;:::i;:::-;;;;;;;;:34;2899:80;;;;-1:-1:-1;;;2899:80:29;;21070:2:76;2899:80:29;;;21052:21:76;21109:2;21089:18;;;21082:30;21148:34;21128:18;;;21121:62;-1:-1:-1;;;21199:18:76;;;21192:31;21240:19;;2899:80:29;20868:397:76;2899:80:29;3025:27;;;3084:1;3025:27;;;:14;:27;;;;;;:40;;;;3053:11;;;;3025:40;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;3025:48:29;;;;;;;;;;;;:61;;;;3153:65;;;;;;;;;;;;;;;;;;;3175:11;;3188;;3153:65;;;;;;3188:11;3153:65;;3188:11;3153:65;;;;;;;;;-1:-1:-1;;3153:65:29;;;;;;;;;;;;;;;;;;;;;;3201:6;;-1:-1:-1;3153:65:29;-1:-1:-1;3209:8:29;;;;;;3153:65;;3209:8;;;;3153:65;;;;;;;;;-1:-1:-1;3153:21:29;;-1:-1:-1;;;3153:65:29:i;:::-;3233:66;3253:11;3266;;3279:6;3287:11;3233:66;;;;;;;;;;:::i;:::-;;;;;;;;2682:624;2511:795;;;;;;:::o;3987:149:6:-;-1:-1:-1;;;;;4102:18:6;;;4076:7;4102:18;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;3987:149::o;6335:255:28:-;1094:13:0;:11;:13::i;:::-;6470:28:28::1;::::0;;::::1;;::::0;;;:15:::1;:28;::::0;;;;;;;:41;;::::1;::::0;;;;;;;;;;:51;;;6536:47;;21991:34:76;;;22041:18;;22034:43;;;;22093:18;;;22086:34;;;6536:47:28::1;::::0;21954:2:76;21939:18;6536:47:28::1;21768:358:76::0;1739:625:45;719:10:16;2041:4:45;2017:29;2009:73;;;;-1:-1:-1;;;2009:73:45;;22333:2:76;2009:73:45;;;22315:21:76;22372:2;22352:18;;;22345:30;22411:33;22391:18;;;22384:61;22462:18;;2009:73:45;22131:355:76;2009:73:45;2119:42;2141:4;2148:3;2153:7;2119:13;:42::i;:::-;2109:52;;2206:3;-1:-1:-1;;;;;2176:43:45;2193:11;2176:43;;;2211:7;2176:43;;;;3855:25:76;;3843:2;3828:18;;3709:177;2176:43:45;;;;;;;;2246:111;;-1:-1:-1;;;2246:111:45;;-1:-1:-1;;;;;2246:33:45;;;;;2285:11;;2246:111;;2298:11;;2311;;;;2324:6;;2332:5;;2339:7;;2348:8;;;;2246:111;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1739:625;;;;;;;;;;:::o;5370:204:28:-;1094:13:0;:11;:13::i;:::-;5470:35:28::1;::::0;::::1;;::::0;;;:19:::1;:35;::::0;;;;:43:::1;::::0;5508:5;;5470:43:::1;:::i;:::-;;5528:39;5545:14;5561:5;;5528:39;;;;;;;;:::i;2074:198:0:-:0;1094:13;:11;:13::i;:::-;-1:-1:-1;;;;;2162:22:0;::::1;2154:73;;;::::0;-1:-1:-1;;;2154:73:0;;23451:2:76;2154:73:0::1;::::0;::::1;23433:21:76::0;23490:2;23470:18;;;23463:30;23529:34;23509:18;;;23502:62;-1:-1:-1;;;23580:18:76;;;23573:36;23626:19;;2154:73:0::1;23249:402:76::0;2154:73:0::1;2237:28;2256:8;2237:18;:28::i;:::-;2074:198:::0;:::o;4239:247:28:-;4411:68;;-1:-1:-1;;;4411:68:28;;23893:6:76;23926:15;;;4411:68:28;;;23908:34:76;23978:15;;23958:18;;;23951:43;4460:4:28;24010:18:76;;;24003:60;24079:18;;;24072:34;;;4380:12:28;;4411:10;-1:-1:-1;;;;;4411:20:28;;;;23855:19:76;;4411:68:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;4411:68:28;;;;;;;;;;;;:::i;:::-;4404:75;4239:247;-1:-1:-1;;;;;4239:247:28:o;985:549:29:-;1172:12;1186:19;1209:199;1256:9;1279:3;1319:34;;;1355:11;1368;1381:6;1389:8;1296:102;;;;;;;;;;;:::i;:::-;;;;-1:-1:-1;;1296:102:29;;;;;;;;;;;;;;-1:-1:-1;;;;;1296:102:29;-1:-1:-1;;;;;;1296:102:29;;;;;;;;;;1217:4;;1209:199;;:33;:199::i;:::-;1171:237;;;;1423:7;1418:110;;1446:71;1466:11;1479;1492:6;1500:8;1510:6;1446:19;:71::i;1359:130:0:-;1247:7;1273:6;-1:-1:-1;;;;;1273:6:0;719:10:16;1422:23:0;1414:68;;;;-1:-1:-1;;;1414:68:0;;25520:2:76;1414:68:0;;;25502:21:76;;;25539:18;;;25532:30;25598:34;25578:18;;;25571:62;25650:18;;1414:68:0;25318:356:76;10457:340:6;-1:-1:-1;;;;;10558:19:6;;10550:68;;;;-1:-1:-1;;;10550:68:6;;25881:2:76;10550:68:6;;;25863:21:76;25920:2;25900:18;;;25893:30;25959:34;25939:18;;;25932:62;-1:-1:-1;;;26010:18:76;;;26003:34;26054:19;;10550:68:6;25679:400:76;10550:68:6;-1:-1:-1;;;;;10636:21:6;;10628:68;;;;-1:-1:-1;;;10628:68:6;;26286:2:76;10628:68:6;;;26268:21:76;26325:2;26305:18;;;26298:30;26364:34;26344:18;;;26337:62;-1:-1:-1;;;26415:18:76;;;26408:32;26457:19;;10628:68:6;26084:398:76;10628:68:6;-1:-1:-1;;;;;10707:18:6;;;;;;;:11;:18;;;;;;;;:27;;;;;;;;;;;;;:36;;;10758:32;;3855:25:76;;;10758:32:6;;3828:18:76;10758:32:6;;;;;;;10457:340;;;:::o;11078:411::-;11178:24;11205:25;11215:5;11222:7;11205:9;:25::i;:::-;11178:52;;-1:-1:-1;;11244:16:6;:37;11240:243;;11325:6;11305:16;:26;;11297:68;;;;-1:-1:-1;;;11297:68:6;;26689:2:76;11297:68:6;;;26671:21:76;26728:2;26708:18;;;26701:30;26767:31;26747:18;;;26740:59;26816:18;;11297:68:6;26487:353:76;11297:68:6;11407:51;11416:5;11423:7;11451:6;11432:16;:25;11407:8;:51::i;:::-;11168:321;11078:411;;;:::o;7456:788::-;-1:-1:-1;;;;;7552:18:6;;7544:68;;;;-1:-1:-1;;;7544:68:6;;27047:2:76;7544:68:6;;;27029:21:76;27086:2;27066:18;;;27059:30;27125:34;27105:18;;;27098:62;-1:-1:-1;;;27176:18:76;;;27169:35;27221:19;;7544:68:6;26845:401:76;7544:68:6;-1:-1:-1;;;;;7630:16:6;;7622:64;;;;-1:-1:-1;;;7622:64:6;;27453:2:76;7622:64:6;;;27435:21:76;27492:2;27472:18;;;27465:30;27531:34;27511:18;;;27504:62;-1:-1:-1;;;27582:18:76;;;27575:33;27625:19;;7622:64:6;27251:399:76;7622:64:6;-1:-1:-1;;;;;7768:15:6;;7746:19;7768:15;;;:9;:15;;;;;;7801:21;;;;7793:72;;;;-1:-1:-1;;;7793:72:6;;27857:2:76;7793:72:6;;;27839:21:76;27896:2;27876:18;;;27869:30;27935:34;27915:18;;;27908:62;-1:-1:-1;;;27986:18:76;;;27979:36;28032:19;;7793:72:6;27655:402:76;7793:72:6;-1:-1:-1;;;;;7899:15:6;;;;;;;:9;:15;;;;;;7917:20;;;7899:38;;8114:13;;;;;;;;;;:23;;;;;;8163:26;;;;;;7931:6;3855:25:76;;3843:2;3828:18;;3709:177;8163:26:6;;;;;;;;8200:37;12073:91;2553:461:45;2753:14;2769:11;2835:20;2858:47;2877:10;2889:15;2896:7;2889:6;:15::i;:::-;9068:48;;;461:1;9068:48;;;32153:49:76;32218:11;;;32211:27;;;;32294:3;32272:16;;;;-1:-1:-1;;;;;;32268:51:76;32254:12;;;32247:73;9068:48:45;;;;;;;;;32336:12:76;;;;9068:48:45;;;8940:183;2858:47;2922:85;;-1:-1:-1;;;2922:85:45;;2835:70;;-1:-1:-1;;;;;;2922:10:45;:23;;;;:85;;2946:11;;2967:4;;2835:70;;2983:7;;2992:14;;2922:85;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;2915:92;;;;;2553:461;;;;;;;;:::o;3604:543::-;3793:16;3812:19;:8;3793:16;3812;:19::i;:::-;3793:38;-1:-1:-1;3846:21:45;;;3842:299;;3883:52;3892:11;3905;3918:6;3926:8;3883;:52::i;:::-;3842:299;;;3956:30;;;509:1;3956:30;3952:189;;;4002:59;4018:11;4031;4044:6;4052:8;4002:15;:59::i;3952:189::-;4092:38;;-1:-1:-1;;;4092:38:45;;29161:2:76;4092:38:45;;;29143:21:76;29200:2;29180:18;;;29173:30;29239;29219:18;;;29212:58;29287:18;;4092:38:45;28959:352:76;4153:821:45;4414:11;4437:66;4452:11;4414;4474:14;4414:11;4437:14;:66::i;:::-;4527:20;4539:7;4527:11;:20::i;:::-;-1:-1:-1;4514:33:45;-1:-1:-1;4566:50:45;4577:5;4584:11;4597:10;4514:33;4566:10;:50::i;:::-;4557:59;;4683:1;4674:6;:10;4666:48;;;;-1:-1:-1;;;4666:48:45;;29518:2:76;4666:48:45;;;29500:21:76;29557:2;29537:18;;;29530:30;-1:-1:-1;;;29576:18:76;;;29569:55;29641:18;;4666:48:45;29316:349:76;4666:48:45;4725:22;4750:46;4769:10;4781:14;4788:6;4781;:14::i;4750:46::-;4725:71;;4806:94;4814:11;4827:9;4838:14;4854:18;4874:14;4890:9;4806:7;:94::i;:::-;4948:10;4941:5;-1:-1:-1;;;;;4916:51:45;4928:11;4916:51;;;4960:6;4916:51;;;;3855:25:76;;3843:2;3828:18;;3709:177;4916:51:45;;;;;;;;4427:547;4153:821;;;;;;;;;:::o;2426:187:0:-;2499:16;2518:6;;-1:-1:-1;;;;;2534:17:0;;;-1:-1:-1;;;;;;2534:17:0;;;;;;2566:40;;2518:6;;;;;;;2566:40;;2499:16;2566:40;2489:124;2426:187;:::o;5428:973:45:-;5758:11;5781:77;5796:11;509:1;5827:14;-1:-1:-1;;;;;5781:77:45;;:14;:77::i;:::-;5882:20;5894:7;5882:11;:20::i;:::-;-1:-1:-1;5869:33:45;-1:-1:-1;5921:50:45;5932:5;5939:11;5952:10;5869:33;5921:10;:50::i;:::-;5912:59;;5998:1;5989:6;:10;5981:48;;;;-1:-1:-1;;;5981:48:45;;29518:2:76;5981:48:45;;;29500:21:76;29557:2;29537:18;;;29530:30;-1:-1:-1;;;29576:18:76;;;29569:55;29641:18;;5981:48:45;29316:349:76;5981:48:45;6107:22;6132:91;6158:10;6170;6182:14;6189:6;6182;:14::i;:::-;6198:8;6208:14;6132:25;:91::i;:::-;6107:116;;6233:94;6241:11;6254:9;6265:14;6281:18;6301:14;6317:9;6233:7;:94::i;:::-;6375:10;6368:5;-1:-1:-1;;;;;6343:51:45;6355:11;6343:51;;;6387:6;6343:51;;;;3855:25:76;;3843:2;3828:18;;3709:177;6343:51:45;;;;;;;;5771:630;5428:973;;;;;;;;;;;:::o;9258:2770:26:-;9374:12;9422:7;9406:12;9422:7;9416:2;9406:12;:::i;:::-;:23;;9398:50;;;;-1:-1:-1;;;9398:50:26;;29872:2:76;9398:50:26;;;29854:21:76;29911:2;29891:18;;;29884:30;-1:-1:-1;;;29930:18:76;;;29923:44;29984:18;;9398:50:26;29670:338:76;9398:50:26;9483:16;9492:7;9483:6;:16;:::i;:::-;9466:6;:13;:33;;9458:63;;;;-1:-1:-1;;;9458:63:26;;30215:2:76;9458:63:26;;;30197:21:76;30254:2;30234:18;;;30227:30;-1:-1:-1;;;30273:18:76;;;30266:47;30330:18;;9458:63:26;30013:341:76;9458:63:26;9532:22;9595:15;;9623:1967;;;;11731:4;11725:11;11712:24;;11917:1;11906:9;11899:20;11965:4;11954:9;11950:20;11944:4;11937:34;9588:2397;;9623:1967;9805:4;9799:11;9786:24;;10464:2;10455:7;10451:16;10846:9;10839:17;10833:4;10829:28;10817:9;10806;10802:25;10798:60;10894:7;10890:2;10886:16;11146:6;11132:9;11125:17;11119:4;11115:28;11103:9;11095:6;11091:22;11087:57;11083:70;10920:425;11179:3;11175:2;11172:11;10920:425;;;11317:9;;11306:21;;11220:4;11212:13;;;;11252;10920:425;;;-1:-1:-1;;11363:26:26;;;11571:2;11554:11;-1:-1:-1;;11550:25:26;11544:4;11537:39;-1:-1:-1;9588:2397:26;-1:-1:-1;12012:9:26;9258:2770;-1:-1:-1;;;;9258:2770:26:o;3020:578:45:-;3289:14;3305:11;3374:20;3397:92;3423:10;3435;3447:15;3454:7;3447:6;:15::i;3397:92::-;3506:85;;-1:-1:-1;;;3506:85:45;;3374:115;;-1:-1:-1;;;;;;3506:10:45;:23;;;;:85;;3530:11;;3551:4;;3374:115;;3567:7;;3576:14;;3506:85;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;3499:92;;;;;3020:578;;;;;;;;;;:::o;1732:415:46:-;1862:4;719:10:16;2009:4:46;-1:-1:-1;;;;;1992:22:46;;;;;;:42;;;2027:7;-1:-1:-1;;;;;2018:16:46;:5;-1:-1:-1;;;;;2018:16:46;;;1992:42;1988:88;;;2036:40;2052:5;2059:7;2068;2036:15;:40::i;:::-;2086:30;2096:5;2103:3;2108:7;2086:9;:30::i;:::-;-1:-1:-1;2133:7:46;;1732:415;-1:-1:-1;;;1732:415:46:o;1111:1274:27:-;1265:4;1271:12;1331;1353:13;1376:24;1413:8;1403:19;;-1:-1:-1;;;;;1403:19:27;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1403:19:27;;1376:46;;1919:1;1890;1853:9;1847:16;1815:4;1804:9;1800:20;1766:1;1728:7;1699:4;1677:267;1665:279;;2011:16;2000:27;;2055:8;2046:7;2043:21;2040:76;;;2094:8;2083:19;;2040:76;2201:7;2188:11;2181:28;2321:7;2318:1;2311:4;2298:11;2294:22;2279:50;2356:8;;;;-1:-1:-1;1111:1274:27;-1:-1:-1;;;;;;1111:1274:27:o;1540:366:29:-;1809:8;1799:19;;;;;;1748:14;:27;1763:11;1748:27;;;;;;;;;;;;;;;1776:11;1748:40;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;1748:48:29;;;;;;;;;:70;;;;1833:66;;;;1847:11;;1860;;1789:6;;1881:8;;1891:7;;1833:66;:::i;:::-;;;;;;;;1540:366;;;;;:::o;12073:91:6:-;;;;:::o;8390:234:45:-;8451:6;;8485:22;2238:9:46;8485:7:45;:22;:::i;:::-;8469:38;-1:-1:-1;;;;;;8525:28:45;;;8517:67;;;;-1:-1:-1;;;8517:67:45;;31821:2:76;8517:67:45;;;31803:21:76;31860:2;31840:18;;;31833:30;31899:28;31879:18;;;31872:56;31945:18;;8517:67:45;31619:350:76;12391:298:26;12465:5;12507:10;:6;12516:1;12507:10;:::i;:::-;12490:6;:13;:27;;12482:59;;;;-1:-1:-1;;;12482:59:26;;32561:2:76;12482:59:26;;;32543:21:76;32600:2;32580:18;;;32573:30;-1:-1:-1;;;32619:18:76;;;32612:49;32678:18;;12482:59:26;32359:343:76;12482:59:26;-1:-1:-1;12617:29:26;12633:3;12617:29;12611:36;;12391:298::o;4980:442:45:-;5129:10;5141:15;5160:28;5179:8;5160:18;:28::i;:::-;5128:60;;-1:-1:-1;5128:60:45;-1:-1:-1;;;;;;5202:16:45;;5198:67;;5247:6;5234:20;;5198:67;5275:11;5289:16;5296:8;5289:6;:16::i;:::-;5275:30;;5324:34;5334:11;5347:2;5351:6;5324:9;:34::i;:::-;5315:43;;5404:2;-1:-1:-1;;;;;5374:41:45;5391:11;5374:41;;;5408:6;5374:41;;;;3855:25:76;;3843:2;3828:18;;3709:177;5374:41:45;;;;;;;;5118:304;;;4980:442;;;;:::o;6407:1855::-;6582:12;6596:10;6608:15;6625:27;6654:17;6675:35;6701:8;6675:25;:35::i;:::-;6581:129;;;;;;;;;;6721:13;6737:15;:28;6753:11;6737:28;;;;;;;;;;;;;;;6766:11;6737:41;;;;;;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;6737:49:45;;;;;;;;;;;;;;-1:-1:-1;6810:16:45;6817:8;6810:6;:16::i;:::-;6796:30;;6951:8;6946:164;;6984:45;6994:11;7015:4;7022:6;6984:9;:45::i;:::-;7043:28;;;;;;;:15;:28;;;;;;;:41;;6975:54;;-1:-1:-1;7095:4:45;;7043:41;;7072:11;;7043:41;:::i;:::-;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7043:49:45;;;;;;;;;;:56;;-1:-1:-1;;7043:56:45;;;;;;;;;;6946:164;-1:-1:-1;;;;;8353:20:45;;;7120:94;;7161:22;;-1:-1:-1;;;;;10623:32:76;;10605:51;;7161:22:45;;10593:2:76;10578:18;7161:22:45;;;;;;;7197:7;;;;;;;;;7120:94;7285:11;7332;7368:6;7407:8;7441:4;7469:2;7496:6;7543:14;7265:17;7625:8;:33;;7648:10;-1:-1:-1;;;;;7625:33:45;;;;7636:9;7625:33;7614:44;;7669:12;7683:19;7706:226;7753:9;7776:3;7816:31;;;7849:10;7861;7873:5;7880;7887:3;7892:7;7901:15;7918:3;7793:129;;;;;;;;;;;;;;;:::i;7706:226::-;7668:264;;;;7947:7;7943:313;;;7985:18;;;;;;8022:59;;;;;;;;;;8057:10;;8069:5;;7985:18;;8022:59;:::i;:::-;;;;;;;;7956:136;7943:313;;;8178:67;8198:10;8210;8222:5;8229:7;8238:6;8178:19;:67::i;:::-;6571:1691;;;;;;;;;;;;;;;;;;6407:1855;;;;:::o;3011:453:28:-;3184:21;3208:28;3221:14;3208:12;:28::i;:::-;3265;;;;3246:16;3265:28;;;:15;:28;;;;;;;;:35;;;;;;;;;;3184:52;;-1:-1:-1;3318:15:28;3310:54;;;;-1:-1:-1;;;3310:54:28;;34193:2:76;3310:54:28;;;34175:21:76;34232:2;34212:18;;;34205:30;34271:28;34251:18;;;34244:56;34317:18;;3310:54:28;33991:350:76;3310:54:28;3402:23;3416:9;3402:11;:23;:::i;:::-;3382:16;:43;;3374:83;;;;-1:-1:-1;;;3374:83:28;;34548:2:76;3374:83:28;;;34530:21:76;34587:2;34567:18;;;34560:30;34626:29;34606:18;;;34599:57;34673:18;;3374:83:28;34346:351:76;8755:179:45;8821:16;;8867:22;2238:9:46;8867:7:45;:22;:::i;:::-;8860:29;-1:-1:-1;8913:14:45;8860:29;8913:7;:14;:::i;:::-;8899:28;;8755:179;;;:::o;1202:319:46:-;1341:4;719:10:16;-1:-1:-1;;;;;1401:16:46;;;;1397:62;;1419:40;1435:5;1442:7;1451;1419:15;:40::i;:::-;1469:21;1475:5;1482:7;1469:5;:21::i;:::-;-1:-1:-1;1507:7:46;;1202:319;-1:-1:-1;;;;1202:319:46:o;2403:602:28:-;2679:32;;;2650:26;2679:32;;;:19;:32;;;;;2650:61;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2729:13;:20;2753:1;2729:25;;2721:86;;;;-1:-1:-1;;;2721:86:28;;35021:2:76;2721:86:28;;;35003:21:76;35060:2;35040:18;;;35033:30;35099:34;35079:18;;;35072:62;-1:-1:-1;;;35150:18:76;;;35143:46;35206:19;;2721:86:28;34819:412:76;2721:86:28;2817:47;2835:11;2848:8;:15;2817:17;:47::i;:::-;2874:124;;-1:-1:-1;;;2874:124:28;;-1:-1:-1;;;;;2874:10:28;:15;;;;2897:10;;2874:124;;2909:11;;2922:13;;2937:8;;2947:14;;2963:18;;2983:14;;2874:124;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2640:365;2403:602;;;;;;:::o;9473:358:45:-;9684:12;509:1;9750:10;9762:9;-1:-1:-1;;;;;10592:23:45;;9799:14;9815:8;9715:109;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;9708:116;;9473:358;;;;;;;:::o;9129:338::-;9211:10;;;9258:19;:8;9211:10;9258:16;:19::i;:::-;:30;;;:55;;;;;9292:8;:15;9311:2;9292:21;9258:55;9250:92;;;;-1:-1:-1;;;9250:92:45;;37002:2:76;9250:92:45;;;36984:21:76;37041:2;37021:18;;;37014:30;-1:-1:-1;;;37060:18:76;;;37053:54;37124:18;;9250:92:45;36800:348:76;9250:92:45;9358:22;:8;9377:2;9358:18;:22::i;:::-;9353:27;-1:-1:-1;9439:21:45;:8;9457:2;9439:17;:21::i;:::-;9428:32;;9129:338;;;:::o;8630:119::-;8695:4;8718:24;2238:9:46;-1:-1:-1;;;;;8718:24:45;;;:::i;1527:199:46:-;1653:4;1669:26;1675:10;1687:7;1669:5;:26::i;:::-;-1:-1:-1;1712:7:46;1527:199;-1:-1:-1;;1527:199:46:o;9837:639:45:-;9971:12;;;10050:20;9971:12;509:1;10137:19;:8;9971:12;10137:16;:19::i;:::-;:39;;;10129:76;;;;-1:-1:-1;;;10129:76:45;;37002:2:76;10129:76:45;;;36984:21:76;37041:2;37021:18;;;37014:30;-1:-1:-1;;;37060:18:76;;;37053:54;37124:18;;10129:76:45;36800:348:76;10129:76:45;10221:22;:8;10240:2;10221:18;:22::i;:::-;10216:27;-1:-1:-1;10302:21:45;:8;10320:2;10302:17;:21::i;:::-;10291:32;-1:-1:-1;10340:22:45;:8;10359:2;10340:18;:22::i;:::-;10333:29;-1:-1:-1;10388:21:45;:8;10406:2;10388:17;:21::i;:::-;10372:37;;10429:40;10444:2;10466;10448:8;:15;:20;;;;:::i;:::-;10429:8;;:40;:14;:40::i;:::-;10419:50;;9837:639;;;;;;;:::o;3470:266:28:-;3552:13;3610:2;3585:14;:21;:27;;3577:68;;;;-1:-1:-1;;;3577:68:28;;37528:2:76;3577:68:28;;;37510:21:76;37567:2;37547:18;;;37540:30;37606;37586:18;;;37579:58;37654:18;;3577:68:28;37326:352:76;3577:68:28;-1:-1:-1;3716:2:28;3696:23;3690:30;;3470:266::o;9375:659:6:-;-1:-1:-1;;;;;9458:21:6;;9450:67;;;;-1:-1:-1;;;9450:67:6;;37885:2:76;9450:67:6;;;37867:21:76;37924:2;37904:18;;;37897:30;37963:34;37943:18;;;37936:62;-1:-1:-1;;;38014:18:76;;;38007:31;38055:19;;9450:67:6;37683:397:76;9450:67:6;-1:-1:-1;;;;;9613:18:6;;9588:22;9613:18;;;:9;:18;;;;;;9649:24;;;;9641:71;;;;-1:-1:-1;;;9641:71:6;;38287:2:76;9641:71:6;;;38269:21:76;38326:2;38306:18;;;38299:30;38365:34;38345:18;;;38338:62;-1:-1:-1;;;38416:18:76;;;38409:32;38458:19;;9641:71:6;38085:398:76;9641:71:6;-1:-1:-1;;;;;9746:18:6;;;;;;:9;:18;;;;;;;;9767:23;;;9746:44;;9883:12;:22;;;;;;;9931:37;3855:25:76;;;9746:18:6;;;9931:37;;3828:18:76;9931:37:6;;;;;;;12073:91;;;:::o;3742:395:28:-;3864:35;;;3840:21;3864:35;;;:22;:35;;;;;;3913:21;3909:135;;-1:-1:-1;618:5:28;3909:135;4077:16;4061:12;:32;;4053:77;;;;-1:-1:-1;;;4053:77:28;;38690:2:76;4053:77:28;;;38672:21:76;;;38709:18;;;38702:30;38768:34;38748:18;;;38741:62;38820:18;;4053:77:28;38488:356:76;12034:351:26;12110:7;12154:11;:6;12163:2;12154:11;:::i;:::-;12137:6;:13;:28;;12129:62;;;;-1:-1:-1;;;12129:62:26;;39051:2:76;12129:62:26;;;39033:21:76;39090:2;39070:18;;;39063:30;-1:-1:-1;;;39109:18:76;;;39102:51;39170:18;;12129:62:26;38849:345:76;12129:62:26;-1:-1:-1;12279:30:26;12295:4;12279:30;12273:37;-1:-1:-1;;;12269:71:26;;;12034:351::o;13311:302::-;13386:6;13429:10;:6;13438:1;13429:10;:::i;:::-;13412:6;:13;:27;;13404:60;;;;-1:-1:-1;;;13404:60:26;;39401:2:76;13404:60:26;;;39383:21:76;39440:2;39420:18;;;39413:30;-1:-1:-1;;;39459:18:76;;;39452:50;39519:18;;13404:60:26;39199:344:76;13404:60:26;-1:-1:-1;13541:29:26;13557:3;13541:29;13535:36;;13311:302::o;8520:535:6:-;-1:-1:-1;;;;;8603:21:6;;8595:65;;;;-1:-1:-1;;;8595:65:6;;39750:2:76;8595:65:6;;;39732:21:76;39789:2;39769:18;;;39762:30;39828:33;39808:18;;;39801:61;39879:18;;8595:65:6;39548:355:76;8595:65:6;8747:6;8731:12;;:22;;;;;;;:::i;:::-;;;;-1:-1:-1;;;;;;;8899:18:6;;;;;;:9;:18;;;;;;;;:28;;;;;;8952:37;3855:25:76;;;8952:37:6;;3828:18:76;8952:37:6;;;;;;;8520:535;;:::o;14550:317:26:-;14626:7;14670:11;:6;14679:2;14670:11;:::i;:::-;14653:6;:13;:28;;14645:62;;;;-1:-1:-1;;;14645:62:26;;40110:2:76;14645:62:26;;;40092:21:76;40149:2;40129:18;;;40122:30;-1:-1:-1;;;40168:18:76;;;40161:51;40229:18;;14645:62:26;39908:345:76;14645:62:26;-1:-1:-1;14791:30:26;14807:4;14791:30;14785:37;;14550:317::o;-1:-1:-1:-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;14:159:76;81:20;;141:6;130:18;;120:29;;110:57;;163:1;160;153:12;110:57;14:159;;;:::o;178:347::-;229:8;239:6;293:3;286:4;278:6;274:17;270:27;260:55;;311:1;308;301:12;260:55;-1:-1:-1;334:20:76;;-1:-1:-1;;;;;366:30:76;;363:50;;;409:1;406;399:12;363:50;446:4;438:6;434:17;422:29;;498:3;491:4;482:6;474;470:19;466:30;463:39;460:59;;;515:1;512;505:12;460:59;178:347;;;;;:::o;530:171::-;597:20;;-1:-1:-1;;;;;646:30:76;;636:41;;626:69;;691:1;688;681:12;706:862;812:6;820;828;836;844;852;905:3;893:9;884:7;880:23;876:33;873:53;;;922:1;919;912:12;873:53;945:28;963:9;945:28;:::i;:::-;935:38;;1024:2;1013:9;1009:18;996:32;-1:-1:-1;;;;;1088:2:76;1080:6;1077:14;1074:34;;;1104:1;1101;1094:12;1074:34;1143:58;1193:7;1184:6;1173:9;1169:22;1143:58;:::i;:::-;1220:8;;-1:-1:-1;1117:84:76;-1:-1:-1;1117:84:76;;-1:-1:-1;1274:37:76;1307:2;1292:18;;1274:37;:::i;:::-;1264:47;;1364:2;1353:9;1349:18;1336:32;1320:48;;1393:2;1383:8;1380:16;1377:36;;;1409:1;1406;1399:12;1377:36;;1448:60;1500:7;1489:8;1478:9;1474:24;1448:60;:::i;:::-;706:862;;;;-1:-1:-1;706:862:76;;-1:-1:-1;706:862:76;;1527:8;;706:862;-1:-1:-1;;;706:862:76:o;1573:286::-;1631:6;1684:2;1672:9;1663:7;1659:23;1655:32;1652:52;;;1700:1;1697;1690:12;1652:52;1726:23;;-1:-1:-1;;;;;;1778:32:76;;1768:43;;1758:71;;1825:1;1822;1815:12;2056:258;2128:1;2138:113;2152:6;2149:1;2146:13;2138:113;;;2228:11;;;2222:18;2209:11;;;2202:39;2174:2;2167:10;2138:113;;;2269:6;2266:1;2263:13;2260:48;;;-1:-1:-1;;2304:1:76;2286:16;;2279:27;2056:258::o;2319:::-;2361:3;2399:5;2393:12;2426:6;2421:3;2414:19;2442:63;2498:6;2491:4;2486:3;2482:14;2475:4;2468:5;2464:16;2442:63;:::i;:::-;2559:2;2538:15;-1:-1:-1;;2534:29:76;2525:39;;;;2566:4;2521:50;;2319:258;-1:-1:-1;;2319:258:76:o;2582:220::-;2731:2;2720:9;2713:21;2694:4;2751:45;2792:2;2781:9;2777:18;2769:6;2751:45;:::i;2807:184::-;2865:6;2918:2;2906:9;2897:7;2893:23;2889:32;2886:52;;;2934:1;2931;2924:12;2886:52;2957:28;2975:9;2957:28;:::i;2996:131::-;-1:-1:-1;;;;;3071:31:76;;3061:42;;3051:70;;3117:1;3114;3107:12;3132:315;3200:6;3208;3261:2;3249:9;3240:7;3236:23;3232:32;3229:52;;;3277:1;3274;3267:12;3229:52;3316:9;3303:23;3335:31;3360:5;3335:31;:::i;:::-;3385:5;3437:2;3422:18;;;;3409:32;;-1:-1:-1;;;3132:315:76:o;3452:252::-;3519:6;3527;3580:2;3568:9;3559:7;3555:23;3551:32;3548:52;;;3596:1;3593;3586:12;3548:52;3619:28;3637:9;3619:28;:::i;3891:456::-;3968:6;3976;3984;4037:2;4025:9;4016:7;4012:23;4008:32;4005:52;;;4053:1;4050;4043:12;4005:52;4092:9;4079:23;4111:31;4136:5;4111:31;:::i;:::-;4161:5;-1:-1:-1;4218:2:76;4203:18;;4190:32;4231:33;4190:32;4231:33;:::i;:::-;3891:456;;4283:7;;-1:-1:-1;;;4337:2:76;4322:18;;;;4309:32;;3891:456::o;4541:160::-;4606:20;;4662:13;;4655:21;4645:32;;4635:60;;4691:1;4688;4681:12;4706:687;4808:6;4816;4824;4832;4840;4848;4901:3;4889:9;4880:7;4876:23;4872:33;4869:53;;;4918:1;4915;4908:12;4869:53;4941:28;4959:9;4941:28;:::i;:::-;4931:38;;5016:2;5005:9;5001:18;4988:32;4978:42;;5067:2;5056:9;5052:18;5039:32;5029:42;;5090:35;5121:2;5110:9;5106:18;5090:35;:::i;:::-;5080:45;;5176:3;5165:9;5161:19;5148:33;-1:-1:-1;;;;;5196:6:76;5193:30;5190:50;;;5236:1;5233;5226:12;5190:50;5275:58;5325:7;5316:6;5305:9;5301:22;5275:58;:::i;5651:481::-;5729:6;5737;5745;5798:2;5786:9;5777:7;5773:23;5769:32;5766:52;;;5814:1;5811;5804:12;5766:52;5837:28;5855:9;5837:28;:::i;:::-;5827:38;;5916:2;5905:9;5901:18;5888:32;-1:-1:-1;;;;;5935:6:76;5932:30;5929:50;;;5975:1;5972;5965:12;5929:50;6014:58;6064:7;6055:6;6044:9;6040:22;6014:58;:::i;:::-;5651:481;;6091:8;;-1:-1:-1;5988:84:76;;-1:-1:-1;;;;5651:481:76:o;6137:127::-;6198:10;6193:3;6189:20;6186:1;6179:31;6229:4;6226:1;6219:15;6253:4;6250:1;6243:15;6269:275;6340:2;6334:9;6405:2;6386:13;;-1:-1:-1;;6382:27:76;6370:40;;-1:-1:-1;;;;;6425:34:76;;6461:22;;;6422:62;6419:88;;;6487:18;;:::i;:::-;6523:2;6516:22;6269:275;;-1:-1:-1;6269:275:76:o;6549:186::-;6597:4;-1:-1:-1;;;;;6622:6:76;6619:30;6616:56;;;6652:18;;:::i;:::-;-1:-1:-1;6718:2:76;6697:15;-1:-1:-1;;6693:29:76;6724:4;6689:40;;6549:186::o;6740:815::-;6824:6;6832;6840;6893:2;6881:9;6872:7;6868:23;6864:32;6861:52;;;6909:1;6906;6899:12;6861:52;6932:28;6950:9;6932:28;:::i;:::-;6922:38;;7011:2;7000:9;6996:18;6983:32;-1:-1:-1;;;;;7030:6:76;7027:30;7024:50;;;7070:1;7067;7060:12;7024:50;7093:22;;7146:4;7138:13;;7134:27;-1:-1:-1;7124:55:76;;7175:1;7172;7165:12;7124:55;7211:2;7198:16;7236:48;7252:31;7280:2;7252:31;:::i;:::-;7236:48;:::i;:::-;7307:2;7300:5;7293:17;7347:7;7342:2;7337;7333;7329:11;7325:20;7322:33;7319:53;;;7368:1;7365;7358:12;7319:53;7423:2;7418;7414;7410:11;7405:2;7398:5;7394:14;7381:45;7467:1;7462:2;7457;7450:5;7446:14;7442:23;7435:34;7488:5;7478:15;;;;;7512:37;7545:2;7534:9;7530:18;7512:37;:::i;:::-;7502:47;;6740:815;;;;;:::o;7742:160::-;7807:5;7852:2;7843:6;7838:3;7834:16;7830:25;7827:45;;;7868:1;7865;7858:12;7827:45;-1:-1:-1;7890:6:76;7742:160;-1:-1:-1;7742:160:76:o;7907:712::-;8034:6;8042;8050;8058;8066;8119:3;8107:9;8098:7;8094:23;8090:33;8087:53;;;8136:1;8133;8126:12;8087:53;8175:9;8162:23;8194:31;8219:5;8194:31;:::i;:::-;8244:5;-1:-1:-1;8268:37:76;8301:2;8286:18;;8268:37;:::i;:::-;8258:47;;8352:2;8341:9;8337:18;8324:32;8314:42;;8403:2;8392:9;8388:18;8375:32;8365:42;;8458:3;8447:9;8443:19;8430:33;-1:-1:-1;;;;;8478:6:76;8475:30;8472:50;;;8518:1;8515;8508:12;8472:50;8541:72;8605:7;8596:6;8585:9;8581:22;8541:72;:::i;:::-;8531:82;;;7907:712;;;;;;;;:::o;8624:247::-;8683:6;8736:2;8724:9;8715:7;8711:23;8707:32;8704:52;;;8752:1;8749;8742:12;8704:52;8791:9;8778:23;8810:31;8835:5;8810:31;:::i;9099:1094::-;9254:6;9262;9270;9278;9286;9294;9302;9310;9363:3;9351:9;9342:7;9338:23;9334:33;9331:53;;;9380:1;9377;9370:12;9331:53;9419:9;9406:23;9438:31;9463:5;9438:31;:::i;:::-;9488:5;-1:-1:-1;9512:37:76;9545:2;9530:18;;9512:37;:::i;:::-;9502:47;;9596:2;9585:9;9581:18;9568:32;9558:42;;9647:2;9636:9;9632:18;9619:32;9609:42;;9702:3;9691:9;9687:19;9674:33;-1:-1:-1;;;;;9767:2:76;9759:6;9756:14;9753:34;;;9783:1;9780;9773:12;9753:34;9822:58;9872:7;9863:6;9852:9;9848:22;9822:58;:::i;:::-;9899:8;;-1:-1:-1;9796:84:76;-1:-1:-1;9796:84:76;;-1:-1:-1;9953:38:76;9986:3;9971:19;;9953:38;:::i;:::-;9943:48;;10044:3;10033:9;10029:19;10016:33;10000:49;;10074:2;10064:8;10061:16;10058:36;;;10090:1;10087;10080:12;10058:36;;10113:74;10179:7;10168:8;10157:9;10153:24;10113:74;:::i;:::-;10103:84;;;9099:1094;;;;;;;;;;;:::o;10198:256::-;10264:6;10272;10325:2;10313:9;10304:7;10300:23;10296:32;10293:52;;;10341:1;10338;10331:12;10293:52;10364:28;10382:9;10364:28;:::i;:::-;10354:38;;10411:37;10444:2;10433:9;10429:18;10411:37;:::i;:::-;10401:47;;10198:256;;;;;:::o;10667:1069::-;10797:6;10805;10813;10821;10829;10837;10845;10853;10861;10914:3;10902:9;10893:7;10889:23;10885:33;10882:53;;;10931:1;10928;10921:12;10882:53;10954:28;10972:9;10954:28;:::i;:::-;10944:38;;11029:2;11018:9;11014:18;11001:32;10991:42;;11080:2;11069:9;11065:18;11052:32;11042:42;;11135:2;11124:9;11120:18;11107:32;-1:-1:-1;;;;;11199:2:76;11191:6;11188:14;11185:34;;;11215:1;11212;11205:12;11185:34;11254:58;11304:7;11295:6;11284:9;11280:22;11254:58;:::i;:::-;11331:8;;-1:-1:-1;11228:84:76;-1:-1:-1;11228:84:76;;-1:-1:-1;11385:38:76;11418:3;11403:19;;11385:38;:::i;:::-;11375:48;;11442:36;11473:3;11462:9;11458:19;11442:36;:::i;:::-;11432:46;;11531:3;11520:9;11516:19;11503:33;11487:49;;11561:2;11551:8;11548:16;11545:36;;;11577:1;11574;11567:12;11545:36;;11616:60;11668:7;11657:8;11646:9;11642:24;11616:60;:::i;:::-;11590:86;;11695:8;11685:18;;;11722:8;11712:18;;;10667:1069;;;;;;;;;;;:::o;11976:622::-;12071:6;12079;12087;12095;12103;12156:3;12144:9;12135:7;12131:23;12127:33;12124:53;;;12173:1;12170;12163:12;12124:53;12196:28;12214:9;12196:28;:::i;:::-;12186:38;;12243:37;12276:2;12265:9;12261:18;12243:37;:::i;:::-;12233:47;;12327:2;12316:9;12312:18;12299:32;12289:42;;12382:2;12371:9;12367:18;12354:32;-1:-1:-1;;;;;12401:6:76;12398:30;12395:50;;;12441:1;12438;12431:12;12395:50;12480:58;12530:7;12521:6;12510:9;12506:22;12480:58;:::i;:::-;11976:622;;;;-1:-1:-1;11976:622:76;;-1:-1:-1;12557:8:76;;12454:84;11976:622;-1:-1:-1;;;11976:622:76:o;12603:388::-;12671:6;12679;12732:2;12720:9;12711:7;12707:23;12703:32;12700:52;;;12748:1;12745;12738:12;12700:52;12787:9;12774:23;12806:31;12831:5;12806:31;:::i;:::-;12856:5;-1:-1:-1;12913:2:76;12898:18;;12885:32;12926:33;12885:32;12926:33;:::i;:::-;12978:7;12968:17;;;12603:388;;;;;:::o;12996:324::-;13071:6;13079;13087;13140:2;13128:9;13119:7;13115:23;13111:32;13108:52;;;13156:1;13153;13146:12;13108:52;13179:28;13197:9;13179:28;:::i;:::-;13169:38;;13226:37;13259:2;13248:9;13244:18;13226:37;:::i;:::-;13216:47;;13310:2;13299:9;13295:18;13282:32;13272:42;;12996:324;;;;;:::o;13325:1205::-;13467:6;13475;13483;13491;13499;13507;13515;13523;13531;13539;13592:3;13580:9;13571:7;13567:23;13563:33;13560:53;;;13609:1;13606;13599:12;13560:53;13632:28;13650:9;13632:28;:::i;:::-;13622:38;;13711:2;13700:9;13696:18;13683:32;-1:-1:-1;;;;;13775:2:76;13767:6;13764:14;13761:34;;;13791:1;13788;13781:12;13761:34;13830:58;13880:7;13871:6;13860:9;13856:22;13830:58;:::i;:::-;13907:8;;-1:-1:-1;13804:84:76;-1:-1:-1;13804:84:76;;-1:-1:-1;13961:37:76;13994:2;13979:18;;13961:37;:::i;:::-;13951:47;;14045:2;14034:9;14030:18;14017:32;14007:42;;14099:3;14088:9;14084:19;14071:33;14058:46;;14113:31;14138:5;14113:31;:::i;:::-;14163:5;;-1:-1:-1;14215:3:76;14200:19;;14187:33;;-1:-1:-1;14273:3:76;14258:19;;14245:33;;14290:16;;;14287:36;;;14319:1;14316;14309:12;14287:36;;14358:60;14410:7;14399:8;14388:9;14384:24;14358:60;:::i;:::-;14332:86;;14437:8;14427:18;;;14464:8;14454:18;;;14519:3;14508:9;14504:19;14491:33;14481:43;;13325:1205;;;;;;;;;;;;;:::o;14535:460::-;14619:6;14627;14635;14643;14696:3;14684:9;14675:7;14671:23;14667:33;14664:53;;;14713:1;14710;14703:12;14664:53;14736:28;14754:9;14736:28;:::i;:::-;14726:38;;14783:37;14816:2;14805:9;14801:18;14783:37;:::i;:::-;14773:47;;14870:2;14859:9;14855:18;14842:32;14883:31;14908:5;14883:31;:::i;:::-;14535:460;;;;-1:-1:-1;14933:5:76;;14985:2;14970:18;14957:32;;-1:-1:-1;;14535:460:76:o;15359:380::-;15438:1;15434:12;;;;15481;;;15502:61;;15556:4;15548:6;15544:17;15534:27;;15502:61;15609:2;15601:6;15598:14;15578:18;15575:38;15572:161;;;15655:10;15650:3;15646:20;15643:1;15636:31;15690:4;15687:1;15680:15;15718:4;15715:1;15708:15;15744:271;15927:6;15919;15914:3;15901:33;15883:3;15953:16;;15978:13;;;15953:16;15744:271;-1:-1:-1;15744:271:76:o;16620:127::-;16681:10;16676:3;16672:20;16669:1;16662:31;16712:4;16709:1;16702:15;16736:4;16733:1;16726:15;16752:128;16792:3;16823:1;16819:6;16816:1;16813:13;16810:39;;;16829:18;;:::i;:::-;-1:-1:-1;16865:9:76;;16752:128::o;16885:266::-;16973:6;16968:3;16961:19;17025:6;17018:5;17011:4;17006:3;17002:14;16989:43;-1:-1:-1;17077:1:76;17052:16;;;17070:4;17048:27;;;17041:38;;;;17133:2;17112:15;;;-1:-1:-1;;17108:29:76;17099:39;;;17095:50;;16885:266::o;17156:326::-;17351:6;17343;17339:19;17328:9;17321:38;17395:2;17390;17379:9;17375:18;17368:30;17302:4;17415:61;17472:2;17461:9;17457:18;17449:6;17441;17415:61;:::i;18154:521::-;18231:4;18237:6;18297:11;18284:25;18391:2;18387:7;18376:8;18360:14;18356:29;18352:43;18332:18;18328:68;18318:96;;18410:1;18407;18400:12;18318:96;18437:33;;18489:20;;;-1:-1:-1;;;;;;18521:30:76;;18518:50;;;18564:1;18561;18554:12;18518:50;18597:4;18585:17;;-1:-1:-1;18628:14:76;18624:27;;;18614:38;;18611:58;;;18665:1;18662;18655:12;19038:125;19078:4;19106:1;19103;19100:8;19097:34;;;19111:18;;:::i;:::-;-1:-1:-1;19148:9:76;;19038:125::o;19574:382::-;19785:6;19777;19772:3;19759:33;19877:2;19873:15;;;;-1:-1:-1;;19869:53:76;19811:16;;19858:65;;;19947:2;19939:11;;19574:382;-1:-1:-1;19574:382:76:o;19961:498::-;20161:4;20190:6;20235:2;20227:6;20223:15;20212:9;20205:34;20287:2;20279:6;20275:15;20270:2;20259:9;20255:18;20248:43;;20327:6;20322:2;20311:9;20307:18;20300:34;20370:3;20365:2;20354:9;20350:18;20343:31;20391:62;20448:3;20437:9;20433:19;20425:6;20417;20391:62;:::i;:::-;20383:70;19961:498;-1:-1:-1;;;;;;;19961:498:76:o;21270:493::-;21519:6;21511;21507:19;21496:9;21489:38;21563:3;21558:2;21547:9;21543:18;21536:31;21470:4;21584:62;21641:3;21630:9;21626:19;21618:6;21610;21584:62;:::i;:::-;-1:-1:-1;;;;;21682:31:76;;;;21677:2;21662:18;;21655:59;-1:-1:-1;21745:2:76;21730:18;21723:34;21576:70;21270:493;-1:-1:-1;;;21270:493:76:o;22491:753::-;22824:6;22816;22812:19;22801:9;22794:38;22868:3;22863:2;22852:9;22848:18;22841:31;22775:4;22895:62;22952:3;22941:9;22937:19;22929:6;22921;22895:62;:::i;:::-;-1:-1:-1;;;;;22997:6:76;22993:31;22988:2;22977:9;22973:18;22966:59;23061:6;23056:2;23045:9;23041:18;23034:34;23105:6;23099:3;23088:9;23084:19;23077:35;23161:9;23153:6;23149:22;23143:3;23132:9;23128:19;23121:51;23189:49;23231:6;23223;23215;23189:49;:::i;:::-;23181:57;22491:753;-1:-1:-1;;;;;;;;;;;22491:753:76:o;24117:634::-;24196:6;24249:2;24237:9;24228:7;24224:23;24220:32;24217:52;;;24265:1;24262;24255:12;24217:52;24298:9;24292:16;-1:-1:-1;;;;;24323:6:76;24320:30;24317:50;;;24363:1;24360;24353:12;24317:50;24386:22;;24439:4;24431:13;;24427:27;-1:-1:-1;24417:55:76;;24468:1;24465;24458:12;24417:55;24497:2;24491:9;24522:48;24538:31;24566:2;24538:31;:::i;24522:48::-;24593:2;24586:5;24579:17;24633:7;24628:2;24623;24619;24615:11;24611:20;24608:33;24605:53;;;24654:1;24651;24644:12;24605:53;24667:54;24718:2;24713;24706:5;24702:14;24697:2;24693;24689:11;24667:54;:::i;24756:557::-;25013:6;25005;25001:19;24990:9;24983:38;25057:3;25052:2;25041:9;25037:18;25030:31;24964:4;25084:46;25125:3;25114:9;25110:19;25102:6;25084:46;:::i;:::-;-1:-1:-1;;;;;25170:6:76;25166:31;25161:2;25150:9;25146:18;25139:59;25246:9;25238:6;25234:22;25229:2;25218:9;25214:18;25207:50;25274:33;25300:6;25292;25274:33;:::i;28062:642::-;28343:6;28331:19;;28313:38;;-1:-1:-1;;;;;28387:32:76;;28382:2;28367:18;;28360:60;28407:3;28451:2;28436:18;;28429:31;;;-1:-1:-1;;28483:46:76;;28509:19;;28501:6;28483:46;:::i;:::-;28579:6;28572:14;28565:22;28560:2;28549:9;28545:18;28538:50;28637:9;28629:6;28625:22;28619:3;28608:9;28604:19;28597:51;28665:33;28691:6;28683;28665:33;:::i;:::-;28657:41;28062:642;-1:-1:-1;;;;;;;;28062:642:76:o;28709:245::-;28788:6;28796;28849:2;28837:9;28828:7;28824:23;28820:32;28817:52;;;28865:1;28862;28855:12;28817:52;-1:-1:-1;;28888:16:76;;28944:2;28929:18;;;28923:25;28888:16;;28923:25;;-1:-1:-1;28709:245:76:o;30359:274::-;30488:3;30526:6;30520:13;30542:53;30588:6;30583:3;30576:4;30568:6;30564:17;30542:53;:::i;:::-;30611:16;;;;;30359:274;-1:-1:-1;;30359:274:76:o;30638:719::-;30941:6;30933;30929:19;30918:9;30911:38;30985:3;30980:2;30969:9;30965:18;30958:31;30892:4;31012:46;31053:3;31042:9;31038:19;31030:6;31012:46;:::i;:::-;-1:-1:-1;;;;;31098:6:76;31094:31;31089:2;31078:9;31074:18;31067:59;31174:9;31166:6;31162:22;31157:2;31146:9;31142:18;31135:50;31208:33;31234:6;31226;31208:33;:::i;:::-;31194:47;;31290:9;31282:6;31278:22;31272:3;31261:9;31257:19;31250:51;31318:33;31344:6;31336;31318:33;:::i;31362:127::-;31423:10;31418:3;31414:20;31411:1;31404:31;31454:4;31451:1;31444:15;31478:4;31475:1;31468:15;31494:120;31534:1;31560;31550:35;;31565:18;;:::i;:::-;-1:-1:-1;31599:9:76;;31494:120::o;32707:891::-;33027:4;33056:3;33098:6;33090;33086:19;33075:9;33068:38;33142:2;33137;33126:9;33122:18;33115:30;33168:45;33209:2;33198:9;33194:18;33186:6;33168:45;:::i;:::-;-1:-1:-1;;;;;33249:31:76;;33244:2;33229:18;;33222:59;33312:2;33297:18;;33290:34;;;-1:-1:-1;;;;;33361:32:76;;33355:3;33340:19;;33333:61;33381:3;33410:19;;33403:35;;;33475:22;;;33469:3;33454:19;;33447:51;33154:59;-1:-1:-1;33515:33:76;33154:59;33533:6;33515:33;:::i;:::-;33507:41;;;33585:6;33579:3;33568:9;33564:19;33557:35;32707:891;;;;;;;;;;;:::o;33603:383::-;33804:2;33793:9;33786:21;33767:4;33824:45;33865:2;33854:9;33850:18;33842:6;33824:45;:::i;:::-;-1:-1:-1;;;;;33905:31:76;;;;33900:2;33885:18;;33878:59;-1:-1:-1;33968:2:76;33953:18;33946:34;33816:53;33603:383;-1:-1:-1;33603:383:76:o;34702:112::-;34734:1;34760;34750:35;;34765:18;;:::i;:::-;-1:-1:-1;34799:9:76;;34702:112::o;35236:840::-;35585:6;35577;35573:19;35562:9;35555:38;35629:3;35624:2;35613:9;35609:18;35602:31;35536:4;35656:46;35697:3;35686:9;35682:19;35674:6;35656:46;:::i;:::-;35750:9;35742:6;35738:22;35733:2;35722:9;35718:18;35711:50;35784:33;35810:6;35802;35784:33;:::i;:::-;-1:-1:-1;;;;;35891:15:76;;;35886:2;35871:18;;35864:43;35944:15;;35938:3;35923:19;;35916:44;35997:22;;;35844:3;35976:19;;35969:51;35770:47;-1:-1:-1;36037:33:76;35770:47;36055:6;36037:33;:::i;:::-;36029:41;35236:840;-1:-1:-1;;;;;;;;;35236:840:76:o;36081:714::-;36403:3;36398;36394:13;36385:6;36380:3;36376:16;36372:36;36367:3;36360:49;36438:6;36434:1;36429:3;36425:11;36418:27;36342:3;-1:-1:-1;;;;;36468:3:76;36464:28;36544:2;36535:6;36530:3;36526:16;36522:25;36517:2;36512:3;36508:12;36501:47;36578:6;36573:2;36568:3;36564:12;36557:28;36637:2;36628:6;36623:3;36619:16;36615:25;36610:2;36605:3;36601:12;36594:47;;36670:6;36664:13;36686:62;36741:6;36736:2;36731:3;36727:12;36720:4;36712:6;36708:17;36686:62;:::i;:::-;36768:16;;;;36786:2;36764:25;;36081:714;-1:-1:-1;;;;;;;36081:714:76:o;37153:168::-;37193:7;37259:1;37255;37251:6;37247:14;37244:1;37241:21;37236:1;37229:9;37222:17;37218:45;37215:71;;;37266:18;;:::i;:::-;-1:-1:-1;37306:9:76;;37153:168::o
Swarm Source
ipfs://64b1bfa8d803624d4e8db89260d0346b3c75e1f4cc649a736fb49c521768f021
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.