Source Code
Overview
MON Balance
MON Value
$0.04 (@ $0.02/MON)Latest 1 from a total of 1 transactions
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Send OFT | 41147187 | 52 days ago | IN | 3.88723642 MON | 0.17940032 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 41147187 | 52 days ago | 1.66085233 MON |
Loading...
Loading
Contract Name:
RemoteHop
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
No with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Ownable2Step, Ownable } from "@openzeppelin/contracts/access/Ownable2Step.sol";
import { OptionsBuilder } from "@fraxfinance/layerzero-v2-upgradeable/oapp/contracts/oapp/libs/OptionsBuilder.sol";
import { SendParam, MessagingFee, IOFT } from "@fraxfinance/layerzero-v2-upgradeable/oapp/contracts/oft/interfaces/IOFT.sol";
import { IOFT2 } from "./interfaces/IOFT2.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ILayerZeroDVN } from "./interfaces/ILayerZeroDVN.sol";
import { ILayerZeroTreasury } from "./interfaces/ILayerZeroTreasury.sol";
import { IExecutor } from "./interfaces/IExecutor.sol";
// ====================================================================
// | ______ _______ |
// | / _____________ __ __ / ____(_____ ____ _____ ________ |
// | / /_ / ___/ __ `| |/_/ / /_ / / __ \/ __ `/ __ \/ ___/ _ \ |
// | / __/ / / / /_/ _> < / __/ / / / / / /_/ / / / / /__/ __/ |
// | /_/ /_/ \__,_/_/|_| /_/ /_/_/ /_/\__,_/_/ /_/\___/\___/ |
// | |
// ====================================================================
// ============================ RemoteHop =============================
// ====================================================================
/// @author Frax Finance: https://github.com/FraxFinance
contract RemoteHop is Ownable2Step {
bool public paused = false;
bytes32 public fraxtalHop;
uint256 public numDVNs = 2;
uint256 public hopFee = 1; // 10000 based so 1 = 0.01%
mapping(uint32 => bytes) public executorOptions;
mapping(address => bool) public approvedOft;
address public immutable EXECUTOR;
address public immutable DVN;
address public immutable TREASURY;
event SendOFT(address oft, address indexed sender, uint32 indexed dstEid, bytes32 indexed to, uint256 amountLD);
error InvalidOFT();
error HopPaused();
error NotEndpoint();
error InsufficientFee();
error RefundFailed();
error ZeroAmountSend();
error ArrayLengthMismatch();
function version() external pure virtual returns (string memory) {
return "1.0.1";
}
constructor(
address _owner,
bytes32 _fraxtalHop,
uint256 _numDVNs,
address _EXECUTOR,
address _DVN,
address _TREASURY,
address[] memory _approvedOfts,
uint32[] memory _eids,
bytes[] memory _executorOptions
) Ownable(_owner) {
fraxtalHop = _fraxtalHop;
numDVNs = _numDVNs;
EXECUTOR = _EXECUTOR;
DVN = _DVN;
TREASURY = _TREASURY;
for (uint256 i = 0; i < _approvedOfts.length; i++) {
approvedOft[_approvedOfts[i]] = true;
}
uint256 _eidCount = _eids.length;
if (_eidCount != _executorOptions.length) revert ArrayLengthMismatch();
for (uint256 i = 0; i < _eidCount; i++) {
executorOptions[_eids[i]] = _executorOptions[i];
}
}
// Admin functions
function recoverERC20(address tokenAddress, address recipient, uint256 tokenAmount) external onlyOwner {
IERC20(tokenAddress).transfer(recipient, tokenAmount);
}
function recoverETH(address recipient, uint256 tokenAmount) external onlyOwner {
payable(recipient).call{ value: tokenAmount }("");
}
function setFraxtalHop(address _fraxtalHop) external {
setFraxtalHop(bytes32(uint256(uint160(_fraxtalHop))));
}
function setFraxtalHop(bytes32 _fraxtalHop) public onlyOwner {
fraxtalHop = _fraxtalHop;
}
function setNumDVNs(uint256 _numDVNs) external onlyOwner {
numDVNs = _numDVNs;
}
function setHopFee(uint256 _hopFee) external onlyOwner {
hopFee = _hopFee;
}
function setExecutorOptions(uint32 eid, bytes memory _options) external onlyOwner {
executorOptions[eid] = _options;
}
function pause(bool _paused) external onlyOwner {
paused = _paused;
}
function toggleOFTApproval(address _oft, bool _approved) external onlyOwner {
approvedOft[_oft] = _approved;
}
// receive ETH
receive() external payable {}
function sendOFT(address _oft, uint32 _dstEid, bytes32 _to, uint256 _amountLD) external payable {
if (paused) revert HopPaused();
if (!approvedOft[_oft]) revert InvalidOFT();
_amountLD = removeDust(_oft, _amountLD);
if (_amountLD == 0) revert ZeroAmountSend();
SafeERC20.safeTransferFrom(IERC20(IOFT(_oft).token()), msg.sender, address(this), _amountLD);
if (_dstEid == 30255) {
_sendToFraxtal(_oft, _to, _amountLD);
} else {
_sendViaFraxtal(_oft, _dstEid, _to, _amountLD);
}
emit SendOFT(_oft, msg.sender, _dstEid, _to, _amountLD);
}
function _sendToFraxtal(address _oft, bytes32 _to, uint256 _amountLD) internal {
// Send the oft
SafeERC20.forceApprove(IERC20(IOFT(_oft).token()), _oft, _amountLD);
SendParam memory sendParam = SendParam({
dstEid: 30255,
to: _to,
amountLD: _amountLD,
minAmountLD: _amountLD,
extraOptions: "",
composeMsg: "",
oftCmd: ""
});
MessagingFee memory fee = IOFT(_oft).quoteSend(sendParam, false);
IOFT(_oft).send{ value: fee.nativeFee }(sendParam, fee, address(this));
// Refund the excess
if (msg.value < fee.nativeFee) revert InsufficientFee();
if (msg.value > fee.nativeFee) {
(bool success, ) = address(msg.sender).call{ value: msg.value - fee.nativeFee }("");
if (!success) revert RefundFailed();
}
}
function _sendViaFraxtal(address _oft, uint32 _dstEid, bytes32 _to, uint256 _amountLD) internal {
// generate arguments
SendParam memory sendParam = _generateSendParam({
_dstEid: _dstEid,
_to: _to,
_amountLD: _amountLD,
_minAmountLD: _amountLD
});
MessagingFee memory fee = IOFT(_oft).quoteSend(sendParam, false);
uint256 finalFee = fee.nativeFee + quoteHop(_dstEid);
if (finalFee > msg.value) revert InsufficientFee();
// Send the oft
SafeERC20.forceApprove(IERC20(IOFT(_oft).token()), _oft, _amountLD);
IOFT(_oft).send{ value: fee.nativeFee }(sendParam, fee, address(this));
// Refund the excess
if (msg.value > finalFee) {
(bool success, ) = address(msg.sender).call{ value: msg.value - finalFee }("");
if (!success) revert RefundFailed();
}
}
function _generateSendParam(
uint32 _dstEid,
bytes32 _to,
uint256 _amountLD,
uint256 _minAmountLD
) internal view returns (SendParam memory sendParam) {
bytes memory options = OptionsBuilder.newOptions();
options = OptionsBuilder.addExecutorLzComposeOption(options, 0, 1000000, 0);
sendParam.dstEid = 30255;
sendParam.to = fraxtalHop;
sendParam.amountLD = _amountLD;
sendParam.minAmountLD = _minAmountLD;
sendParam.extraOptions = options;
sendParam.composeMsg = abi.encode(_to, _dstEid);
}
function quote(
address _oft,
uint32 _dstEid,
bytes32 _to,
uint256 _amountLD
) public view returns (MessagingFee memory fee) {
_amountLD = removeDust(_oft, _amountLD);
if (_dstEid == 30255) {
SendParam memory sendParam = SendParam({
dstEid: 30255,
to: _to,
amountLD: _amountLD,
minAmountLD: _amountLD,
extraOptions: "",
composeMsg: "",
oftCmd: ""
});
fee = IOFT(_oft).quoteSend(sendParam, false);
} else {
SendParam memory sendParam = _generateSendParam({
_dstEid: _dstEid,
_to: _to,
_amountLD: _amountLD,
_minAmountLD: _amountLD
});
fee = IOFT(_oft).quoteSend(sendParam, false);
fee.nativeFee += quoteHop(_dstEid);
}
}
function quoteHop(uint32 _dstEid) public view returns (uint256 finalFee) {
uint256 dvnFee = ILayerZeroDVN(DVN).getFee(_dstEid, 5, address(this), "");
bytes memory options = executorOptions[_dstEid];
if (options.length == 0) options = hex"01001101000000000000000000000000000493E0";
uint256 executorFee = IExecutor(EXECUTOR).getFee(_dstEid, address(this), 36, options);
uint256 totalFee = dvnFee * numDVNs + executorFee;
uint256 treasuryFee = ILayerZeroTreasury(TREASURY).getFee(address(this), _dstEid, totalFee, false);
finalFee = totalFee + treasuryFee;
finalFee = (finalFee * (10000 + hopFee)) / 10000;
}
function removeDust(address oft, uint256 _amountLD) internal view returns (uint256) {
uint256 decimalConversionRate = IOFT2(oft).decimalConversionRate();
return (_amountLD / decimalConversionRate) * decimalConversionRate;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol";
import { SafeCast } from "@openzeppelin/contracts-4.8.1/utils/math/SafeCast.sol";
import { ExecutorOptions } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/ExecutorOptions.sol";
import { DVNOptions } from "@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/DVNOptions.sol";
/**
* @title OptionsBuilder
* @dev Library for building and encoding various message options.
*/
library OptionsBuilder {
using SafeCast for uint256;
using BytesLib for bytes;
// Constants for options types
uint16 internal constant TYPE_1 = 1; // legacy options type 1
uint16 internal constant TYPE_2 = 2; // legacy options type 2
uint16 internal constant TYPE_3 = 3;
// Custom error message
error InvalidSize(uint256 max, uint256 actual);
error InvalidOptionType(uint16 optionType);
// Modifier to ensure only options of type 3 are used
modifier onlyType3(bytes memory _options) {
if (_options.toUint16(0) != TYPE_3) revert InvalidOptionType(_options.toUint16(0));
_;
}
/**
* @dev Creates a new options container with type 3.
* @return options The newly created options container.
*/
function newOptions() internal pure returns (bytes memory) {
return abi.encodePacked(TYPE_3);
}
/**
* @dev Adds an executor LZ receive option to the existing options.
* @param _options The existing options container.
* @param _gas The gasLimit used on the lzReceive() function in the OApp.
* @param _value The msg.value passed to the lzReceive() function in the OApp.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed by the executor
* eg. if (_gas: 200k, and _value: 1 ether) AND (_gas: 100k, _value: 0.5 ether) are sent in an option to the LayerZeroEndpoint,
* that becomes (300k, 1.5 ether) when the message is executed on the remote lzReceive() function.
*/
function addExecutorLzReceiveOption(
bytes memory _options,
uint128 _gas,
uint128 _value
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeLzReceiveOption(_gas, _value);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZRECEIVE, option);
}
/**
* @dev Adds an executor native drop option to the existing options.
* @param _options The existing options container.
* @param _amount The amount for the native value that is airdropped to the 'receiver'.
* @param _receiver The receiver address for the native drop option.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed by the executor on the remote chain.
*/
function addExecutorNativeDropOption(
bytes memory _options,
uint128 _amount,
bytes32 _receiver
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeNativeDropOption(_amount, _receiver);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_NATIVE_DROP, option);
}
/**
* @dev Adds an executor LZ compose option to the existing options.
* @param _options The existing options container.
* @param _index The index for the lzCompose() function call.
* @param _gas The gasLimit for the lzCompose() function call.
* @param _value The msg.value for the lzCompose() function call.
* @return options The updated options container.
*
* @dev When multiples of this option are added, they are summed PER index by the executor on the remote chain.
* @dev If the OApp sends N lzCompose calls on the remote, you must provide N incremented indexes starting with 0.
* ie. When your remote OApp composes (N = 3) messages, you must set this option for index 0,1,2
*/
function addExecutorLzComposeOption(
bytes memory _options,
uint16 _index,
uint128 _gas,
uint128 _value
) internal pure onlyType3(_options) returns (bytes memory) {
bytes memory option = ExecutorOptions.encodeLzComposeOption(_index, _gas, _value);
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_LZCOMPOSE, option);
}
/**
* @dev Adds an executor ordered execution option to the existing options.
* @param _options The existing options container.
* @return options The updated options container.
*/
function addExecutorOrderedExecutionOption(
bytes memory _options
) internal pure onlyType3(_options) returns (bytes memory) {
return addExecutorOption(_options, ExecutorOptions.OPTION_TYPE_ORDERED_EXECUTION, bytes(""));
}
/**
* @dev Adds a DVN pre-crime option to the existing options.
* @param _options The existing options container.
* @param _dvnIdx The DVN index for the pre-crime option.
* @return options The updated options container.
*/
function addDVNPreCrimeOption(
bytes memory _options,
uint8 _dvnIdx
) internal pure onlyType3(_options) returns (bytes memory) {
return addDVNOption(_options, _dvnIdx, DVNOptions.OPTION_TYPE_PRECRIME, bytes(""));
}
/**
* @dev Adds an executor option to the existing options.
* @param _options The existing options container.
* @param _optionType The type of the executor option.
* @param _option The encoded data for the executor option.
* @return options The updated options container.
*/
function addExecutorOption(
bytes memory _options,
uint8 _optionType,
bytes memory _option
) internal pure onlyType3(_options) returns (bytes memory) {
return
abi.encodePacked(
_options,
ExecutorOptions.WORKER_ID,
_option.length.toUint16() + 1, // +1 for optionType
_optionType,
_option
);
}
/**
* @dev Adds a DVN option to the existing options.
* @param _options The existing options container.
* @param _dvnIdx The DVN index for the DVN option.
* @param _optionType The type of the DVN option.
* @param _option The encoded data for the DVN option.
* @return options The updated options container.
*/
function addDVNOption(
bytes memory _options,
uint8 _dvnIdx,
uint8 _optionType,
bytes memory _option
) internal pure onlyType3(_options) returns (bytes memory) {
return
abi.encodePacked(
_options,
DVNOptions.WORKER_ID,
_option.length.toUint16() + 2, // +2 for optionType and dvnIdx
_dvnIdx,
_optionType,
_option
);
}
/**
* @dev Encodes legacy options of type 1.
* @param _executionGas The gasLimit value passed to lzReceive().
* @return legacyOptions The encoded legacy options.
*/
function encodeLegacyOptionsType1(uint256 _executionGas) internal pure returns (bytes memory) {
if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);
return abi.encodePacked(TYPE_1, _executionGas);
}
/**
* @dev Encodes legacy options of type 2.
* @param _executionGas The gasLimit value passed to lzReceive().
* @param _nativeForDst The amount of native air dropped to the receiver.
* @param _receiver The _nativeForDst receiver address.
* @return legacyOptions The encoded legacy options of type 2.
*/
function encodeLegacyOptionsType2(
uint256 _executionGas,
uint256 _nativeForDst,
bytes memory _receiver // @dev Use bytes instead of bytes32 in legacy type 2 for _receiver.
) internal pure returns (bytes memory) {
if (_executionGas > type(uint128).max) revert InvalidSize(type(uint128).max, _executionGas);
if (_nativeForDst > type(uint128).max) revert InvalidSize(type(uint128).max, _nativeForDst);
if (_receiver.length > 32) revert InvalidSize(32, _receiver.length);
return abi.encodePacked(TYPE_2, _executionGas, _nativeForDst, _receiver);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { MessagingReceipt, MessagingFee } from "../../oapp/OAppSenderUpgradeable.sol";
/**
* @dev Struct representing token parameters for the OFT send() operation.
*/
struct SendParam {
uint32 dstEid; // Destination endpoint ID.
bytes32 to; // Recipient address.
uint256 amountLD; // Amount to send in local decimals.
uint256 minAmountLD; // Minimum amount to send in local decimals.
bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
bytes composeMsg; // The composed message for the send() operation.
bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}
/**
* @dev Struct representing OFT limit information.
* @dev These amounts can change dynamically and are up the the specific oft implementation.
*/
struct OFTLimit {
uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}
/**
* @dev Struct representing OFT receipt information.
*/
struct OFTReceipt {
uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
// @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}
/**
* @dev Struct representing OFT fee details.
* @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
*/
struct OFTFeeDetail {
int256 feeAmountLD; // Amount of the fee in local decimals.
string description; // Description of the fee.
}
/**
* @title IOFT
* @dev Interface for the OftChain (OFT) token.
* @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
* @dev This specific interface ID is '0x02e49c2c'.
*/
interface IOFT {
// Custom error messages
error InvalidLocalDecimals();
error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);
// Events
event OFTSent(
// GUID of the OFT message.
// Destination Endpoint ID.
// Address of the sender on the src chain.
// Amount of tokens sent in local decimals.
// Amount of tokens received in local decimals.
bytes32 indexed guid,
uint32 dstEid,
address indexed fromAddress,
uint256 amountSentLD,
uint256 amountReceivedLD
);
event OFTReceived(
// GUID of the OFT message.
// Source Endpoint ID.
// Address of the recipient on the dst chain.
// Amount of tokens received in local decimals.
bytes32 indexed guid,
uint32 srcEid,
address indexed toAddress,
uint256 amountReceivedLD
);
/**
* @notice Retrieves interfaceID and the version of the OFT.
* @return interfaceId The interface ID.
* @return version The version.
*
* @dev interfaceId: This specific interface ID is '0x02e49c2c'.
* @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
* @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
* ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
*/
function oftVersion() external view returns (bytes4 interfaceId, uint64 version);
/**
* @notice Retrieves the address of the token associated with the OFT.
* @return token The address of the ERC20 token implementation.
*/
function token() external view returns (address);
/**
* @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev Allows things like wallet implementers to determine integration requirements,
* without understanding the underlying token implementation.
*/
function approvalRequired() external view returns (bool);
/**
* @notice Retrieves the shared decimals of the OFT.
* @return sharedDecimals The shared decimals of the OFT.
*/
function sharedDecimals() external view returns (uint8);
/**
* @notice Provides a quote for OFT-related operations.
* @param _sendParam The parameters for the send operation.
* @return limit The OFT limit information.
* @return oftFeeDetails The details of OFT fees.
* @return receipt The OFT receipt information.
*/
function quoteOFT(
SendParam calldata _sendParam
) external view returns (OFTLimit memory, OFTFeeDetail[] memory oftFeeDetails, OFTReceipt memory);
/**
* @notice Provides a quote for the send() operation.
* @param _sendParam The parameters for the send() operation.
* @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
* @return fee The calculated LayerZero messaging fee from the send() operation.
*
* @dev MessagingFee: LayerZero msg fee
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
*/
function quoteSend(SendParam calldata _sendParam, bool _payInLzToken) external view returns (MessagingFee memory);
/**
* @notice Executes the send() operation.
* @param _sendParam The parameters for the send operation.
* @param _fee The fee information supplied by the caller.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess funds from fees etc. on the src.
* @return receipt The LayerZero messaging receipt from the send() operation.
* @return oftReceipt The OFT receipt information.
*
* @dev MessagingReceipt: LayerZero msg receipt
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function send(
SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IOFT2 {
function decimalConversionRate() external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ILayerZeroDVN {
// @notice query the dvn fee for relaying block information to the destination chain
// @param _dstEid the destination endpoint identifier
// @param _confirmations - block confirmation delay before relaying blocks
// @param _sender - the source sending contract address
// @param _options - options
function getFee(
uint32 _dstEid,
uint64 _confirmations,
address _sender,
bytes calldata _options
) external view returns (uint256 fee);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface ILayerZeroTreasury {
function getFee(
address _sender,
uint32 _dstEid,
uint256 _totalNativeFee,
bool _payInLzToken
) external view returns (uint256 fee);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IExecutor {
// @notice query the executor price for relaying the payload and its proof to the destination chain
// @param _dstEid - the destination endpoint identifier
// @param _sender - the source sending contract address. executors may apply price discrimination to senders
// @param _calldataSize - dynamic data size of message + caller params
// @param _options - optional parameters for extra service plugins, e.g. sending dust tokens at the destination chain
function getFee(
uint32 _dstEid,
address _sender,
uint256 _calldataSize,
bytes calldata _options
) external view returns (uint256 price);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: 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, uint256 _start, uint256 _length ) internal pure returns (bytes memory) { // We're using the unchecked block below because otherwise execution ends // with the native overflow error code. unchecked { 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, uint256 _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, uint256 _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, uint256 _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, uint256 _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, uint256 _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, uint256 _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, uint256 _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, uint256 _start) internal pure returns (uint256) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint256 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint256 _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 (last updated v4.8.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toUint248(uint256 value) internal pure returns (uint248) {
require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits");
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toUint240(uint256 value) internal pure returns (uint240) {
require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits");
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toUint232(uint256 value) internal pure returns (uint232) {
require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits");
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.2._
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toUint216(uint256 value) internal pure returns (uint216) {
require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits");
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toUint208(uint256 value) internal pure returns (uint208) {
require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits");
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toUint200(uint256 value) internal pure returns (uint200) {
require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits");
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toUint192(uint256 value) internal pure returns (uint192) {
require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits");
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toUint184(uint256 value) internal pure returns (uint184) {
require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits");
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toUint176(uint256 value) internal pure returns (uint176) {
require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits");
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toUint168(uint256 value) internal pure returns (uint168) {
require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits");
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toUint160(uint256 value) internal pure returns (uint160) {
require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits");
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toUint152(uint256 value) internal pure returns (uint152) {
require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits");
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toUint144(uint256 value) internal pure returns (uint144) {
require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits");
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toUint136(uint256 value) internal pure returns (uint136) {
require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits");
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v2.5._
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toUint120(uint256 value) internal pure returns (uint120) {
require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits");
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toUint112(uint256 value) internal pure returns (uint112) {
require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits");
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toUint104(uint256 value) internal pure returns (uint104) {
require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits");
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.2._
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toUint88(uint256 value) internal pure returns (uint88) {
require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits");
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toUint80(uint256 value) internal pure returns (uint80) {
require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits");
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toUint72(uint256 value) internal pure returns (uint72) {
require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits");
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v2.5._
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toUint56(uint256 value) internal pure returns (uint56) {
require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits");
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toUint48(uint256 value) internal pure returns (uint48) {
require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits");
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toUint40(uint256 value) internal pure returns (uint40) {
require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits");
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v2.5._
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toUint24(uint256 value) internal pure returns (uint24) {
require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits");
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v2.5._
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v2.5._
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*
* _Available since v3.0._
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*
* _Available since v4.7._
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
require(downcasted == value, "SafeCast: value doesn't fit in 248 bits");
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*
* _Available since v4.7._
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
require(downcasted == value, "SafeCast: value doesn't fit in 240 bits");
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*
* _Available since v4.7._
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
require(downcasted == value, "SafeCast: value doesn't fit in 232 bits");
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*
* _Available since v4.7._
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
require(downcasted == value, "SafeCast: value doesn't fit in 224 bits");
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*
* _Available since v4.7._
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
require(downcasted == value, "SafeCast: value doesn't fit in 216 bits");
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*
* _Available since v4.7._
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
require(downcasted == value, "SafeCast: value doesn't fit in 208 bits");
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*
* _Available since v4.7._
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
require(downcasted == value, "SafeCast: value doesn't fit in 200 bits");
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*
* _Available since v4.7._
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
require(downcasted == value, "SafeCast: value doesn't fit in 192 bits");
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*
* _Available since v4.7._
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
require(downcasted == value, "SafeCast: value doesn't fit in 184 bits");
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*
* _Available since v4.7._
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
require(downcasted == value, "SafeCast: value doesn't fit in 176 bits");
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*
* _Available since v4.7._
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
require(downcasted == value, "SafeCast: value doesn't fit in 168 bits");
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*
* _Available since v4.7._
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
require(downcasted == value, "SafeCast: value doesn't fit in 160 bits");
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*
* _Available since v4.7._
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
require(downcasted == value, "SafeCast: value doesn't fit in 152 bits");
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*
* _Available since v4.7._
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
require(downcasted == value, "SafeCast: value doesn't fit in 144 bits");
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*
* _Available since v4.7._
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
require(downcasted == value, "SafeCast: value doesn't fit in 136 bits");
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
require(downcasted == value, "SafeCast: value doesn't fit in 128 bits");
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*
* _Available since v4.7._
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
require(downcasted == value, "SafeCast: value doesn't fit in 120 bits");
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*
* _Available since v4.7._
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
require(downcasted == value, "SafeCast: value doesn't fit in 112 bits");
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*
* _Available since v4.7._
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
require(downcasted == value, "SafeCast: value doesn't fit in 104 bits");
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*
* _Available since v4.7._
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
require(downcasted == value, "SafeCast: value doesn't fit in 96 bits");
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*
* _Available since v4.7._
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
require(downcasted == value, "SafeCast: value doesn't fit in 88 bits");
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*
* _Available since v4.7._
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
require(downcasted == value, "SafeCast: value doesn't fit in 80 bits");
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*
* _Available since v4.7._
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
require(downcasted == value, "SafeCast: value doesn't fit in 72 bits");
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
require(downcasted == value, "SafeCast: value doesn't fit in 64 bits");
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*
* _Available since v4.7._
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
require(downcasted == value, "SafeCast: value doesn't fit in 56 bits");
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*
* _Available since v4.7._
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
require(downcasted == value, "SafeCast: value doesn't fit in 48 bits");
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*
* _Available since v4.7._
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
require(downcasted == value, "SafeCast: value doesn't fit in 40 bits");
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
require(downcasted == value, "SafeCast: value doesn't fit in 32 bits");
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*
* _Available since v4.7._
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
require(downcasted == value, "SafeCast: value doesn't fit in 24 bits");
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
require(downcasted == value, "SafeCast: value doesn't fit in 16 bits");
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*
* _Available since v3.0._
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
import { CalldataBytesLib } from "../../libs/CalldataBytesLib.sol";
library ExecutorOptions {
using CalldataBytesLib for bytes;
uint8 internal constant WORKER_ID = 1;
uint8 internal constant OPTION_TYPE_LZRECEIVE = 1;
uint8 internal constant OPTION_TYPE_NATIVE_DROP = 2;
uint8 internal constant OPTION_TYPE_LZCOMPOSE = 3;
uint8 internal constant OPTION_TYPE_ORDERED_EXECUTION = 4;
error Executor_InvalidLzReceiveOption();
error Executor_InvalidNativeDropOption();
error Executor_InvalidLzComposeOption();
/// @dev decode the next executor option from the options starting from the specified cursor
/// @param _options [executor_id][executor_option][executor_id][executor_option]...
/// executor_option = [option_size][option_type][option]
/// option_size = len(option_type) + len(option)
/// executor_id: uint8, option_size: uint16, option_type: uint8, option: bytes
/// @param _cursor the cursor to start decoding from
/// @return optionType the type of the option
/// @return option the option of the executor
/// @return cursor the cursor to start decoding the next executor option
function nextExecutorOption(
bytes calldata _options,
uint256 _cursor
) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
unchecked {
// skip worker id
cursor = _cursor + 1;
// read option size
uint16 size = _options.toU16(cursor);
cursor += 2;
// read option type
optionType = _options.toU8(cursor);
// startCursor and endCursor are used to slice the option from _options
uint256 startCursor = cursor + 1; // skip option type
uint256 endCursor = cursor + size;
option = _options[startCursor:endCursor];
cursor += size;
}
}
function decodeLzReceiveOption(bytes calldata _option) internal pure returns (uint128 gas, uint128 value) {
if (_option.length != 16 && _option.length != 32) revert Executor_InvalidLzReceiveOption();
gas = _option.toU128(0);
value = _option.length == 32 ? _option.toU128(16) : 0;
}
function decodeNativeDropOption(bytes calldata _option) internal pure returns (uint128 amount, bytes32 receiver) {
if (_option.length != 48) revert Executor_InvalidNativeDropOption();
amount = _option.toU128(0);
receiver = _option.toB32(16);
}
function decodeLzComposeOption(
bytes calldata _option
) internal pure returns (uint16 index, uint128 gas, uint128 value) {
if (_option.length != 18 && _option.length != 34) revert Executor_InvalidLzComposeOption();
index = _option.toU16(0);
gas = _option.toU128(2);
value = _option.length == 34 ? _option.toU128(18) : 0;
}
function encodeLzReceiveOption(uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
return _value == 0 ? abi.encodePacked(_gas) : abi.encodePacked(_gas, _value);
}
function encodeNativeDropOption(uint128 _amount, bytes32 _receiver) internal pure returns (bytes memory) {
return abi.encodePacked(_amount, _receiver);
}
function encodeLzComposeOption(uint16 _index, uint128 _gas, uint128 _value) internal pure returns (bytes memory) {
return _value == 0 ? abi.encodePacked(_index, _gas) : abi.encodePacked(_index, _gas, _value);
}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
import { BytesLib } from "solidity-bytes-utils/contracts/BytesLib.sol";
import { BitMap256 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/messagelib/libs/BitMaps.sol";
import { CalldataBytesLib } from "@layerzerolabs/lz-evm-protocol-v2/contracts/libs/CalldataBytesLib.sol";
library DVNOptions {
using CalldataBytesLib for bytes;
using BytesLib for bytes;
uint8 internal constant WORKER_ID = 2;
uint8 internal constant OPTION_TYPE_PRECRIME = 1;
error DVN_InvalidDVNIdx();
error DVN_InvalidDVNOptions(uint256 cursor);
/// @dev group dvn options by its idx
/// @param _options [dvn_id][dvn_option][dvn_id][dvn_option]...
/// dvn_option = [option_size][dvn_idx][option_type][option]
/// option_size = len(dvn_idx) + len(option_type) + len(option)
/// dvn_id: uint8, dvn_idx: uint8, option_size: uint16, option_type: uint8, option: bytes
/// @return dvnOptions the grouped options, still share the same format of _options
/// @return dvnIndices the dvn indices
function groupDVNOptionsByIdx(
bytes memory _options
) internal pure returns (bytes[] memory dvnOptions, uint8[] memory dvnIndices) {
if (_options.length == 0) return (dvnOptions, dvnIndices);
uint8 numDVNs = getNumDVNs(_options);
// if there is only 1 dvn, we can just return the whole options
if (numDVNs == 1) {
dvnOptions = new bytes[](1);
dvnOptions[0] = _options;
dvnIndices = new uint8[](1);
dvnIndices[0] = _options.toUint8(3); // dvn idx
return (dvnOptions, dvnIndices);
}
// otherwise, we need to group the options by dvn_idx
dvnIndices = new uint8[](numDVNs);
dvnOptions = new bytes[](numDVNs);
unchecked {
uint256 cursor = 0;
uint256 start = 0;
uint8 lastDVNIdx = 255; // 255 is an invalid dvn_idx
while (cursor < _options.length) {
++cursor; // skip worker_id
// optionLength asserted in getNumDVNs (skip check)
uint16 optionLength = _options.toUint16(cursor);
cursor += 2;
// dvnIdx asserted in getNumDVNs (skip check)
uint8 dvnIdx = _options.toUint8(cursor);
// dvnIdx must equal to the lastDVNIdx for the first option
// so it is always skipped in the first option
// this operation slices out options whenever the scan finds a different lastDVNIdx
if (lastDVNIdx == 255) {
lastDVNIdx = dvnIdx;
} else if (dvnIdx != lastDVNIdx) {
uint256 len = cursor - start - 3; // 3 is for worker_id and option_length
bytes memory opt = _options.slice(start, len);
_insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, opt);
// reset the start and lastDVNIdx
start += len;
lastDVNIdx = dvnIdx;
}
cursor += optionLength;
}
// skip check the cursor here because the cursor is asserted in getNumDVNs
// if we have reached the end of the options, we need to process the last dvn
uint256 size = cursor - start;
bytes memory op = _options.slice(start, size);
_insertDVNOptions(dvnOptions, dvnIndices, lastDVNIdx, op);
// revert dvnIndices to start from 0
for (uint8 i = 0; i < numDVNs; ++i) {
--dvnIndices[i];
}
}
}
function _insertDVNOptions(
bytes[] memory _dvnOptions,
uint8[] memory _dvnIndices,
uint8 _dvnIdx,
bytes memory _newOptions
) internal pure {
// dvnIdx starts from 0 but default value of dvnIndices is 0,
// so we tell if the slot is empty by adding 1 to dvnIdx
if (_dvnIdx == 255) revert DVN_InvalidDVNIdx();
uint8 dvnIdxAdj = _dvnIdx + 1;
for (uint256 j = 0; j < _dvnIndices.length; ++j) {
uint8 index = _dvnIndices[j];
if (dvnIdxAdj == index) {
_dvnOptions[j] = abi.encodePacked(_dvnOptions[j], _newOptions);
break;
} else if (index == 0) {
// empty slot, that means it is the first time we see this dvn
_dvnIndices[j] = dvnIdxAdj;
_dvnOptions[j] = _newOptions;
break;
}
}
}
/// @dev get the number of unique dvns
/// @param _options the format is the same as groupDVNOptionsByIdx
function getNumDVNs(bytes memory _options) internal pure returns (uint8 numDVNs) {
uint256 cursor = 0;
BitMap256 bitmap;
// find number of unique dvn_idx
unchecked {
while (cursor < _options.length) {
++cursor; // skip worker_id
uint16 optionLength = _options.toUint16(cursor);
cursor += 2;
if (optionLength < 2) revert DVN_InvalidDVNOptions(cursor); // at least 1 byte for dvn_idx and 1 byte for option_type
uint8 dvnIdx = _options.toUint8(cursor);
// if dvnIdx is not set, increment numDVNs
// max num of dvns is 255, 255 is an invalid dvn_idx
// The order of the dvnIdx is not required to be sequential, as enforcing the order may weaken
// the composability of the options. e.g. if we refrain from enforcing the order, an OApp that has
// already enforced certain options can append additional options to the end of the enforced
// ones without restrictions.
if (dvnIdx == 255) revert DVN_InvalidDVNIdx();
if (!bitmap.get(dvnIdx)) {
++numDVNs;
bitmap = bitmap.set(dvnIdx);
}
cursor += optionLength;
}
}
if (cursor != _options.length) revert DVN_InvalidDVNOptions(cursor);
}
/// @dev decode the next dvn option from _options starting from the specified cursor
/// @param _options the format is the same as groupDVNOptionsByIdx
/// @param _cursor the cursor to start decoding
/// @return optionType the type of the option
/// @return option the option
/// @return cursor the cursor to start decoding the next option
function nextDVNOption(
bytes calldata _options,
uint256 _cursor
) internal pure returns (uint8 optionType, bytes calldata option, uint256 cursor) {
unchecked {
// skip worker id
cursor = _cursor + 1;
// read option size
uint16 size = _options.toU16(cursor);
cursor += 2;
// read option type
optionType = _options.toU8(cursor + 1); // skip dvn_idx
// startCursor and endCursor are used to slice the option from _options
uint256 startCursor = cursor + 2; // skip option type and dvn_idx
uint256 endCursor = cursor + size;
option = _options[startCursor:endCursor];
cursor += size;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { SafeERC20, IERC20 } from "@openzeppelin/contracts-4.8.1/token/ERC20/utils/SafeERC20.sol";
import { MessagingParams, MessagingFee, MessagingReceipt } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
import { OAppCoreUpgradeable } from "./OAppCoreUpgradeable.sol";
/**
* @title OAppSender
* @dev Abstract contract implementing the OAppSender functionality for sending messages to a LayerZero endpoint.
*/
abstract contract OAppSenderUpgradeable is OAppCoreUpgradeable {
using SafeERC20 for IERC20;
// Custom error messages
error NotEnoughNative(uint256 msgValue);
error LzTokenUnavailable();
// @dev The version of the OAppSender implementation.
// @dev Version is bumped when changes are made to this contract.
uint64 internal constant SENDER_VERSION = 1;
/**
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppSender_init() internal onlyInitializing {}
function __OAppSender_init_unchained() internal onlyInitializing {}
/**
* @notice Retrieves the OApp version information.
* @return senderVersion The version of the OAppSender.sol contract.
* @return receiverVersion The version of the OAppReceiver.sol contract.
*
* @dev Providing 0 as the default for OAppReceiver version. Indicates that the OAppReceiver is not implemented.
* ie. this is a SEND only OApp.
* @dev If the OApp uses both OAppSender and OAppReceiver, then this needs to be override returning the correct versions
*/
function oAppVersion() public view virtual returns (uint64 senderVersion, uint64 receiverVersion) {
return (SENDER_VERSION, 0);
}
/**
* @dev Internal function to interact with the LayerZero EndpointV2.quote() for fee calculation.
* @param _dstEid The destination endpoint ID.
* @param _message The message payload.
* @param _options Additional options for the message.
* @param _payInLzToken Flag indicating whether to pay the fee in LZ tokens.
* @return fee The calculated MessagingFee for the message.
* - nativeFee: The native fee for the message.
* - lzTokenFee: The LZ token fee for the message.
*/
function _quote(
uint32 _dstEid,
bytes memory _message,
bytes memory _options,
bool _payInLzToken
) internal view virtual returns (MessagingFee memory fee) {
return
endpoint.quote(
MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _payInLzToken),
address(this)
);
}
/**
* @dev Internal function to interact with the LayerZero EndpointV2.send() for sending a message.
* @param _dstEid The destination endpoint ID.
* @param _message The message payload.
* @param _options Additional options for the message.
* @param _fee The calculated LayerZero fee for the message.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess fee values sent to the endpoint.
* @return receipt The receipt for the sent message.
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function _lzSend(
uint32 _dstEid,
bytes memory _message,
bytes memory _options,
MessagingFee memory _fee,
address _refundAddress
) internal virtual returns (MessagingReceipt memory receipt) {
// @dev Push corresponding fees to the endpoint, any excess is sent back to the _refundAddress from the endpoint.
uint256 messageValue = _payNative(_fee.nativeFee);
if (_fee.lzTokenFee > 0) _payLzToken(_fee.lzTokenFee);
return
endpoint.send{ value: messageValue }(
// solhint-disable-next-line check-send-result
MessagingParams(_dstEid, _getPeerOrRevert(_dstEid), _message, _options, _fee.lzTokenFee > 0),
_refundAddress
);
}
/**
* @dev Internal function to pay the native fee associated with the message.
* @param _nativeFee The native fee to be paid.
* @return nativeFee The amount of native currency paid.
*
* @dev If the OApp needs to initiate MULTIPLE LayerZero messages in a single transaction,
* this will need to be overridden because msg.value would contain multiple lzFees.
* @dev Should be overridden in the event the LayerZero endpoint requires a different native currency.
* @dev Some EVMs use an ERC20 as a method for paying transactions/gasFees.
* @dev The endpoint is EITHER/OR, ie. it will NOT support both types of native payment at a time.
*/
function _payNative(uint256 _nativeFee) internal virtual returns (uint256 nativeFee) {
if (msg.value != _nativeFee) revert NotEnoughNative(msg.value);
return _nativeFee;
}
/**
* @dev Internal function to pay the LZ token fee associated with the message.
* @param _lzTokenFee The LZ token fee to be paid.
*
* @dev If the caller is trying to pay in the specified lzToken, then the lzTokenFee is passed to the endpoint.
* @dev Any excess sent, is passed back to the specified _refundAddress in the _lzSend().
*/
function _payLzToken(uint256 _lzTokenFee) internal virtual {
// @dev Cannot cache the token because it is not immutable in the endpoint.
address lzToken = endpoint.lzToken();
if (lzToken == address(0)) revert LzTokenUnavailable();
// Pay LZ token fee by sending tokens to the endpoint.
IERC20(lzToken).safeTransferFrom(msg.sender, address(endpoint), _lzTokenFee);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: LZBL-1.2
pragma solidity ^0.8.20;
library CalldataBytesLib {
function toU8(bytes calldata _bytes, uint256 _start) internal pure returns (uint8) {
return uint8(_bytes[_start]);
}
function toU16(bytes calldata _bytes, uint256 _start) internal pure returns (uint16) {
unchecked {
uint256 end = _start + 2;
return uint16(bytes2(_bytes[_start:end]));
}
}
function toU32(bytes calldata _bytes, uint256 _start) internal pure returns (uint32) {
unchecked {
uint256 end = _start + 4;
return uint32(bytes4(_bytes[_start:end]));
}
}
function toU64(bytes calldata _bytes, uint256 _start) internal pure returns (uint64) {
unchecked {
uint256 end = _start + 8;
return uint64(bytes8(_bytes[_start:end]));
}
}
function toU128(bytes calldata _bytes, uint256 _start) internal pure returns (uint128) {
unchecked {
uint256 end = _start + 16;
return uint128(bytes16(_bytes[_start:end]));
}
}
function toU256(bytes calldata _bytes, uint256 _start) internal pure returns (uint256) {
unchecked {
uint256 end = _start + 32;
return uint256(bytes32(_bytes[_start:end]));
}
}
function toAddr(bytes calldata _bytes, uint256 _start) internal pure returns (address) {
unchecked {
uint256 end = _start + 20;
return address(bytes20(_bytes[_start:end]));
}
}
function toB32(bytes calldata _bytes, uint256 _start) internal pure returns (bytes32) {
unchecked {
uint256 end = _start + 32;
return bytes32(_bytes[_start:end]);
}
}
}// SPDX-License-Identifier: MIT
// modified from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/BitMaps.sol
pragma solidity ^0.8.20;
type BitMap256 is uint256;
using BitMaps for BitMap256 global;
library BitMaps {
/**
* @dev Returns whether the bit at `index` is set.
*/
function get(BitMap256 bitmap, uint8 index) internal pure returns (bool) {
uint256 mask = 1 << index;
return BitMap256.unwrap(bitmap) & mask != 0;
}
/**
* @dev Sets the bit at `index`.
*/
function set(BitMap256 bitmap, uint8 index) internal pure returns (BitMap256) {
uint256 mask = 1 << index;
return BitMap256.wrap(BitMap256.unwrap(bitmap) | mask);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import { IMessageLibManager } from "./IMessageLibManager.sol";
import { IMessagingComposer } from "./IMessagingComposer.sol";
import { IMessagingChannel } from "./IMessagingChannel.sol";
import { IMessagingContext } from "./IMessagingContext.sol";
struct MessagingParams {
uint32 dstEid;
bytes32 receiver;
bytes message;
bytes options;
bool payInLzToken;
}
struct MessagingReceipt {
bytes32 guid;
uint64 nonce;
MessagingFee fee;
}
struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}
struct Origin {
uint32 srcEid;
bytes32 sender;
uint64 nonce;
}
interface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {
event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);
event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);
event PacketDelivered(Origin origin, address receiver);
event LzReceiveAlert(
address indexed receiver,
address indexed executor,
Origin origin,
bytes32 guid,
uint256 gas,
uint256 value,
bytes message,
bytes extraData,
bytes reason
);
event LzTokenSet(address token);
event DelegateSet(address sender, address delegate);
function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);
function send(
MessagingParams calldata _params,
address _refundAddress
) external payable returns (MessagingReceipt memory);
function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;
function verifiable(Origin calldata _origin, address _receiver) external view returns (bool);
function initializable(Origin calldata _origin, address _receiver) external view returns (bool);
function lzReceive(
Origin calldata _origin,
address _receiver,
bytes32 _guid,
bytes calldata _message,
bytes calldata _extraData
) external payable;
// oapp can burn messages partially by calling this function with its own business logic if messages are verified in order
function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;
function setLzToken(address _lzToken) external;
function lzToken() external view returns (address);
function nativeToken() external view returns (address);
function setDelegate(address _delegate) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable-4.8.1/access/OwnableUpgradeable.sol";
import { IOAppCore, ILayerZeroEndpointV2 } from "./interfaces/IOAppCore.sol";
/**
* @title OAppCore
* @dev Abstract contract implementing the IOAppCore interface with basic OApp configurations.
*/
abstract contract OAppCoreUpgradeable is IOAppCore, OwnableUpgradeable {
struct OAppCoreStorage {
mapping(uint32 => bytes32) peers;
}
// keccak256(abi.encode(uint256(keccak256("layerzerov2.storage.oappcore")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OAppCoreStorageLocation =
0x72ab1bc1039b79dc4724ffca13de82c96834302d3c7e0d4252232d4b2dd8f900;
function _getOAppCoreStorage() internal pure returns (OAppCoreStorage storage $) {
assembly {
$.slot := OAppCoreStorageLocation
}
}
// The LayerZero endpoint associated with the given OApp
ILayerZeroEndpointV2 public immutable endpoint;
/**
* @dev Constructor to initialize the OAppCore with the provided endpoint and delegate.
* @param _endpoint The address of the LOCAL Layer Zero endpoint.
*/
constructor(address _endpoint) {
endpoint = ILayerZeroEndpointV2(_endpoint);
}
/**
* @dev Initializes the OAppCore with the provided delegate.
* @param _delegate The delegate capable of making OApp configurations inside of the endpoint.
*
* @dev The delegate typically should be set as the owner of the contract.
* @dev Ownable is not initialized here on purpose. It should be initialized in the child contract to
* accommodate the different version of Ownable.
*/
function __OAppCore_init(address _delegate) internal onlyInitializing {
__OAppCore_init_unchained(_delegate);
}
function __OAppCore_init_unchained(address _delegate) internal onlyInitializing {
if (_delegate == address(0)) revert InvalidDelegate();
endpoint.setDelegate(_delegate);
}
/**
* @notice Returns the peer address (OApp instance) associated with a specific endpoint.
* @param _eid The endpoint ID.
* @return peer The address of the peer associated with the specified endpoint.
*/
function peers(uint32 _eid) public view override returns (bytes32) {
OAppCoreStorage storage $ = _getOAppCoreStorage();
return $.peers[_eid];
}
/**
* @notice Sets the peer address (OApp instance) for a corresponding endpoint.
* @param _eid The endpoint ID.
* @param _peer The address of the peer to be associated with the corresponding endpoint.
*
* @dev Only the owner/admin of the OApp can call this function.
* @dev Indicates that the peer is trusted to send LayerZero messages to this OApp.
* @dev Set this to bytes32(0) to remove the peer address.
* @dev Peer is a bytes32 to accommodate non-evm chains.
*/
function setPeer(uint32 _eid, bytes32 _peer) public virtual onlyOwner {
OAppCoreStorage storage $ = _getOAppCoreStorage();
$.peers[_eid] = _peer;
emit PeerSet(_eid, _peer);
}
/**
* @notice Internal function to get the peer address associated with a specific endpoint; reverts if NOT set.
* ie. the peer is set to bytes32(0).
* @param _eid The endpoint ID.
* @return peer The address of the peer associated with the specified endpoint.
*/
function _getPeerOrRevert(uint32 _eid) internal view virtual returns (bytes32) {
OAppCoreStorage storage $ = _getOAppCoreStorage();
bytes32 peer = $.peers[_eid];
if (peer == bytes32(0)) revert NoPeer(_eid);
return peer;
}
/**
* @notice Sets the delegate address for the OApp.
* @param _delegate The address of the delegate to be set.
*
* @dev Only the owner/admin of the OApp can call this function.
* @dev Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.
*/
function setDelegate(address _delegate) public onlyOwner {
endpoint.setDelegate(_delegate);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return 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
pragma solidity >=0.8.0;
struct SetConfigParam {
uint32 eid;
uint32 configType;
bytes config;
}
interface IMessageLibManager {
struct Timeout {
address lib;
uint256 expiry;
}
event LibraryRegistered(address newLib);
event DefaultSendLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibrarySet(uint32 eid, address newLib);
event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);
event SendLibrarySet(address sender, uint32 eid, address newLib);
event ReceiveLibrarySet(address receiver, uint32 eid, address newLib);
event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);
function registerLibrary(address _lib) external;
function isRegisteredLibrary(address _lib) external view returns (bool);
function getRegisteredLibraries() external view returns (address[] memory);
function setDefaultSendLibrary(uint32 _eid, address _newLib) external;
function defaultSendLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function defaultReceiveLibrary(uint32 _eid) external view returns (address);
function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;
function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);
function isSupportedEid(uint32 _eid) external view returns (bool);
function isValidReceiveLibrary(address _receiver, uint32 _eid, address _lib) external view returns (bool);
/// ------------------- OApp interfaces -------------------
function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;
function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);
function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);
function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;
function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);
function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _expiry) external;
function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);
function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;
function getConfig(
address _oapp,
address _lib,
uint32 _eid,
uint32 _configType
) external view returns (bytes memory config);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingComposer {
event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);
event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);
event LzComposeAlert(
address indexed from,
address indexed to,
address indexed executor,
bytes32 guid,
uint16 index,
uint256 gas,
uint256 value,
bytes message,
bytes extraData,
bytes reason
);
function composeQueue(
address _from,
address _to,
bytes32 _guid,
uint16 _index
) external view returns (bytes32 messageHash);
function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;
function lzCompose(
address _from,
address _to,
bytes32 _guid,
uint16 _index,
bytes calldata _message,
bytes calldata _extraData
) external payable;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingChannel {
event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);
event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);
function eid() external view returns (uint32);
// this is an emergency function if a message cannot be verified for some reasons
// required to provide _nextNonce to avoid race condition
function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;
function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;
function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);
function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);
function inboundPayloadHash(
address _receiver,
uint32 _srcEid,
bytes32 _sender,
uint64 _nonce
) external view returns (bytes32);
function lazyInboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
interface IMessagingContext {
function isSendingMessage() external view returns (bool);
function getSendContext() external view returns (uint32 dstEid, address sender);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* 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 OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { ILayerZeroEndpointV2 } from "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol";
/**
* @title IOAppCore
*/
interface IOAppCore {
// Custom error messages
error OnlyPeer(uint32 eid, bytes32 sender);
error NoPeer(uint32 eid);
error InvalidEndpointCall();
error InvalidDelegate();
// Event emitted when a peer (OApp) is set for a corresponding endpoint
event PeerSet(uint32 eid, bytes32 peer);
/**
* @notice Retrieves the OApp version information.
* @return senderVersion The version of the OAppSender.sol contract.
* @return receiverVersion The version of the OAppReceiver.sol contract.
*/
function oAppVersion() external view returns (uint64 senderVersion, uint64 receiverVersion);
/**
* @notice Retrieves the LayerZero endpoint associated with the OApp.
* @return iEndpoint The LayerZero endpoint as an interface.
*/
function endpoint() external view returns (ILayerZeroEndpointV2 iEndpoint);
/**
* @notice Retrieves the peer (OApp) associated with a corresponding endpoint.
* @param _eid The endpoint ID.
* @return peer The peer address (OApp instance) associated with the corresponding endpoint.
*/
function peers(uint32 _eid) external view returns (bytes32 peer);
/**
* @notice Sets the peer address (OApp instance) for a corresponding endpoint.
* @param _eid The endpoint ID.
* @param _peer The address of the peer to be associated with the corresponding endpoint.
*/
function setPeer(uint32 _eid, bytes32 _peer) external;
/**
* @notice Sets the delegate address for the OApp Core.
* @param _delegate The address of the delegate to be set.
*/
function setDelegate(address _delegate) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return 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 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);
}
}
}{
"remappings": [
"frax-std/=node_modules/frax-standard-solidity/src/",
"@prb/test/=node_modules/@prb/test/",
"forge-std/=node_modules/forge-std/src/",
"ds-test/=node_modules/ds-test/src/",
"@openzeppelin/=node_modules/@openzeppelin/",
"@axelar-network/=node_modules/@axelar-network/",
"@chainlink/=node_modules/@chainlink/",
"@eth-optimism/=node_modules/@eth-optimism/",
"@fraxfinance/=node_modules/@fraxfinance/",
"@layerzerolabs/=node_modules/@layerzerolabs/",
"frax-standard-solidity/=node_modules/frax-standard-solidity/",
"hardhat-deploy/=node_modules/hardhat-deploy/",
"solidity-bytes-utils/=node_modules/solidity-bytes-utils/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_fraxtalHop","type":"bytes32"},{"internalType":"uint256","name":"_numDVNs","type":"uint256"},{"internalType":"address","name":"_EXECUTOR","type":"address"},{"internalType":"address","name":"_DVN","type":"address"},{"internalType":"address","name":"_TREASURY","type":"address"},{"internalType":"address[]","name":"_approvedOfts","type":"address[]"},{"internalType":"uint32[]","name":"_eids","type":"uint32[]"},{"internalType":"bytes[]","name":"_executorOptions","type":"bytes[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArrayLengthMismatch","type":"error"},{"inputs":[],"name":"HopPaused","type":"error"},{"inputs":[],"name":"InsufficientFee","type":"error"},{"inputs":[],"name":"InvalidOFT","type":"error"},{"inputs":[{"internalType":"uint16","name":"optionType","type":"uint16"}],"name":"InvalidOptionType","type":"error"},{"inputs":[],"name":"NotEndpoint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"RefundFailed","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"ZeroAmountSend","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oft","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint32","name":"dstEid","type":"uint32"},{"indexed":true,"internalType":"bytes32","name":"to","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"amountLD","type":"uint256"}],"name":"SendOFT","type":"event"},{"inputs":[],"name":"DVN","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EXECUTOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TREASURY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"approvedOft","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"executorOptions","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fraxtalHop","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hopFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numDVNs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_oft","type":"address"},{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bytes32","name":"_to","type":"bytes32"},{"internalType":"uint256","name":"_amountLD","type":"uint256"}],"name":"quote","outputs":[{"components":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"lzTokenFee","type":"uint256"}],"internalType":"struct MessagingFee","name":"fee","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_dstEid","type":"uint32"}],"name":"quoteHop","outputs":[{"internalType":"uint256","name":"finalFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oft","type":"address"},{"internalType":"uint32","name":"_dstEid","type":"uint32"},{"internalType":"bytes32","name":"_to","type":"bytes32"},{"internalType":"uint256","name":"_amountLD","type":"uint256"}],"name":"sendOFT","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint32","name":"eid","type":"uint32"},{"internalType":"bytes","name":"_options","type":"bytes"}],"name":"setExecutorOptions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_fraxtalHop","type":"address"}],"name":"setFraxtalHop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_fraxtalHop","type":"bytes32"}],"name":"setFraxtalHop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_hopFee","type":"uint256"}],"name":"setHopFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numDVNs","type":"uint256"}],"name":"setNumDVNs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oft","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"toggleOFTApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"stateMutability":"payable","type":"receive"}]Contract Creation Code
60e06040525f600160146101000a81548160ff0219169083151502179055506002600355600160045534801562000034575f80fd5b50604051620042593803806200425983398181016040528101906200005a919062000913565b885f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603620000ce575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401620000c5919062000a5a565b60405180910390fd5b620000df81620002e860201b60201c565b5087600281905550866003819055508573ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250508473ffffffffffffffffffffffffffffffffffffffff1660a08173ffffffffffffffffffffffffffffffffffffffff16815250508373ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff16815250505f5b83518110156200021657600160065f868481518110620001b157620001b062000a75565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff02191690831515021790555080806001019150506200018c565b505f825190508151811462000257576040517fa24a13a600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b81811015620002d75782818151811062000278576200027762000a75565b5b602002602001015160055f86848151811062000299576200029862000a75565b5b602002602001015163ffffffff1663ffffffff1681526020019081526020015f209081620002c8919062000cd0565b50808060010191505062000259565b505050505050505050505062000db4565b60015f6101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556200031d816200032060201b60201c565b50565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6200041d82620003f2565b9050919050565b6200042f8162000411565b81146200043a575f80fd5b50565b5f815190506200044d8162000424565b92915050565b5f819050919050565b620004678162000453565b811462000472575f80fd5b50565b5f8151905062000485816200045c565b92915050565b5f819050919050565b6200049f816200048b565b8114620004aa575f80fd5b50565b5f81519050620004bd8162000494565b92915050565b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6200050f82620004c7565b810181811067ffffffffffffffff82111715620005315762000530620004d7565b5b80604052505050565b5f62000545620003e1565b905062000553828262000504565b919050565b5f67ffffffffffffffff821115620005755762000574620004d7565b5b602082029050602081019050919050565b5f80fd5b5f620005a06200059a8462000558565b6200053a565b90508083825260208201905060208402830185811115620005c657620005c562000586565b5b835b81811015620005f35780620005de88826200043d565b845260208401935050602081019050620005c8565b5050509392505050565b5f82601f830112620006145762000613620004c3565b5b8151620006268482602086016200058a565b91505092915050565b5f67ffffffffffffffff8211156200064c576200064b620004d7565b5b602082029050602081019050919050565b5f63ffffffff82169050919050565b62000677816200065d565b811462000682575f80fd5b50565b5f8151905062000695816200066c565b92915050565b5f620006b1620006ab846200062f565b6200053a565b90508083825260208201905060208402830185811115620006d757620006d662000586565b5b835b81811015620007045780620006ef888262000685565b845260208401935050602081019050620006d9565b5050509392505050565b5f82601f830112620007255762000724620004c3565b5b8151620007378482602086016200069b565b91505092915050565b5f67ffffffffffffffff8211156200075d576200075c620004d7565b5b602082029050602081019050919050565b5f80fd5b5f67ffffffffffffffff8211156200078f576200078e620004d7565b5b6200079a82620004c7565b9050602081019050919050565b5f5b83811015620007c6578082015181840152602081019050620007a9565b5f8484015250505050565b5f620007e7620007e18462000772565b6200053a565b9050828152602081018484840111156200080657620008056200076e565b5b62000813848285620007a7565b509392505050565b5f82601f830112620008325762000831620004c3565b5b815162000844848260208601620007d1565b91505092915050565b5f620008636200085d8462000740565b6200053a565b9050808382526020820190506020840283018581111562000889576200088862000586565b5b835b81811015620008d757805167ffffffffffffffff811115620008b257620008b1620004c3565b5b808601620008c189826200081b565b855260208501945050506020810190506200088b565b5050509392505050565b5f82601f830112620008f857620008f7620004c3565b5b81516200090a8482602086016200084d565b91505092915050565b5f805f805f805f805f6101208a8c031215620009345762000933620003ea565b5b5f620009438c828d016200043d565b9950506020620009568c828d0162000475565b9850506040620009698c828d01620004ad565b97505060606200097c8c828d016200043d565b96505060806200098f8c828d016200043d565b95505060a0620009a28c828d016200043d565b94505060c08a015167ffffffffffffffff811115620009c657620009c5620003ee565b5b620009d48c828d01620005fd565b93505060e08a015167ffffffffffffffff811115620009f857620009f7620003ee565b5b62000a068c828d016200070e565b9250506101008a015167ffffffffffffffff81111562000a2b5762000a2a620003ee565b5b62000a398c828d01620008e1565b9150509295985092959850929598565b62000a548162000411565b82525050565b5f60208201905062000a6f5f83018462000a49565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168062000af157607f821691505b60208210810362000b075762000b0662000aac565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830262000b6b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000b2e565b62000b77868362000b2e565b95508019841693508086168417925050509392505050565b5f819050919050565b5f62000bb862000bb262000bac846200048b565b62000b8f565b6200048b565b9050919050565b5f819050919050565b62000bd38362000b98565b62000beb62000be28262000bbf565b84845462000b3a565b825550505050565b5f90565b62000c0162000bf3565b62000c0e81848462000bc8565b505050565b5b8181101562000c355762000c295f8262000bf7565b60018101905062000c14565b5050565b601f82111562000c845762000c4e8162000b0d565b62000c598462000b1f565b8101602085101562000c69578190505b62000c8162000c788562000b1f565b83018262000c13565b50505b505050565b5f82821c905092915050565b5f62000ca65f198460080262000c89565b1980831691505092915050565b5f62000cc0838362000c95565b9150826002028217905092915050565b62000cdb8262000aa2565b67ffffffffffffffff81111562000cf75762000cf6620004d7565b5b62000d03825462000ad9565b62000d1082828562000c39565b5f60209050601f83116001811462000d46575f841562000d31578287015190505b62000d3d858262000cb3565b86555062000dac565b601f19841662000d568662000b0d565b5f5b8281101562000d7f5784890151825560018201915060208501945060208101905062000d58565b8683101562000d9f578489015162000d9b601f89168262000c95565b8355505b6001600288020188555050505b505050505050565b60805160a05160c05161346562000df45f395f81816106f00152610eb501525f818161063d0152610c6f01525f8181610abc0152610df701526134655ff3fe60806040526004361061019f575f3560e01c8063630dc7cb116100eb578063b218b19811610089578063e30c397811610063578063e30c397814610560578063ec1278d61461058a578063efb79985146105b2578063f2fde38b146105ee576101a6565b8063b218b198146104d0578063c616f376146104fa578063d393f07214610536576101a6565b806377958f87116100c557806377958f871461042c57806379ba5097146104545780638153924b1461046a5780638da5cb5b146104a6576101a6565b8063630dc7cb146103c457806367fb4738146103ee578063715018a614610416576101a6565b80633e832c901161015857806359c7c5161161013257806359c7c5161461030e5780635b461c831461034a5780635c975abb146103725780635e8c18da1461039c576101a6565b80633e832c90146102a05780635135db46146102bc57806354fd4d50146102e4576101a6565b806302329a29146101aa578063104db380146101d25780631171bda9146101fc57806324df604b146102245780632d2c55651461024e5780633e0c062914610278576101a6565b366101a657005b5f80fd5b3480156101b5575f80fd5b506101d060048036038101906101cb9190612023565b610616565b005b3480156101dd575f80fd5b506101e661063b565b6040516101f3919061208d565b60405180910390f35b348015610207575f80fd5b50610222600480360381019061021d9190612103565b61065f565b005b34801561022f575f80fd5b506102386106e8565b6040516102459190612162565b60405180910390f35b348015610259575f80fd5b506102626106ee565b60405161026f919061208d565b60405180910390f35b348015610283575f80fd5b5061029e6004803603810190610299919061217b565b610712565b005b6102ba60048036038101906102b59190612225565b610784565b005b3480156102c7575f80fd5b506102e260048036038101906102dd91906123c5565b610992565b005b3480156102ef575f80fd5b506102f86109c9565b6040516103059190612499565b60405180910390f35b348015610319575f80fd5b50610334600480360381019061032f91906124b9565b610a06565b60405161034191906124f3565b60405180910390f35b348015610355575f80fd5b50610370600480360381019061036b91906124b9565b610a23565b005b34801561037d575f80fd5b50610386610a47565b60405161039391906124f3565b60405180910390f35b3480156103a7575f80fd5b506103c260048036038101906103bd919061250c565b610a5a565b005b3480156103cf575f80fd5b506103d8610aba565b6040516103e5919061208d565b60405180910390f35b3480156103f9575f80fd5b50610414600480360381019061040f919061254a565b610ade565b005b348015610421575f80fd5b5061042a610af0565b005b348015610437575f80fd5b50610452600480360381019061044d9190612575565b610b03565b005b34801561045f575f80fd5b50610468610b15565b005b348015610475575f80fd5b50610490600480360381019061048b91906125a0565b610ba3565b60405161049d919061261d565b60405180910390f35b3480156104b1575f80fd5b506104ba610c3e565b6040516104c7919061208d565b60405180910390f35b3480156104db575f80fd5b506104e4610c65565b6040516104f19190612162565b60405180910390f35b348015610505575f80fd5b50610520600480360381019061051b91906125a0565b610c6b565b60405161052d9190612162565b60405180910390f35b348015610541575f80fd5b5061054a610f95565b604051610557919061264c565b60405180910390f35b34801561056b575f80fd5b50610574610f9b565b604051610581919061208d565b60405180910390f35b348015610595575f80fd5b506105b060048036038101906105ab919061254a565b610fc3565b005b3480156105bd575f80fd5b506105d860048036038101906105d39190612225565b610fd5565b6040516105e591906126a1565b60405180910390f35b3480156105f9575f80fd5b50610614600480360381019061060f91906124b9565b611195565b005b61061e611241565b80600160146101000a81548160ff02191690831515021790555050565b7f000000000000000000000000000000000000000000000000000000000000000081565b610667611241565b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b81526004016106a29291906126ba565b6020604051808303815f875af11580156106be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106e291906126f5565b50505050565b60045481565b7f000000000000000000000000000000000000000000000000000000000000000081565b61071a611241565b8173ffffffffffffffffffffffffffffffffffffffff168160405161073e9061274d565b5f6040518083038185875af1925050503d805f8114610778576040519150601f19603f3d011682016040523d82523d5f602084013e61077d565b606091505b5050505050565b600160149054906101000a900460ff16156107cb576040517f819f993900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1661084b576040517f7413e48600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61085584826112c8565b90505f8103610890576040517f4fdf5da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109088473ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109009190612775565b333084611359565b61762f8363ffffffff1603610927576109228483836113db565b610934565b610933848484846116b8565b5b818363ffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbc9ee36b6ca0bdd5b3840e6d329dd19a2490d880c7ce24d9818aa593adfb35be87856040516109849291906126ba565b60405180910390a450505050565b61099a611241565b8060055f8463ffffffff1663ffffffff1681526020019081526020015f2090816109c4919061299a565b505050565b60606040518060400160405280600581526020017f312e302e31000000000000000000000000000000000000000000000000000000815250905090565b6006602052805f5260405f205f915054906101000a900460ff1681565b610a448173ffffffffffffffffffffffffffffffffffffffff165f1b610b03565b50565b600160149054906101000a900460ff1681565b610a62611241565b8060065f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b610ae6611241565b8060048190555050565b610af8611241565b610b015f61194f565b565b610b0b611241565b8060028190555050565b5f610b1e61197f565b90508073ffffffffffffffffffffffffffffffffffffffff16610b3f610f9b565b73ffffffffffffffffffffffffffffffffffffffff1614610b9757806040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610b8e919061208d565b60405180910390fd5b610ba08161194f565b50565b6005602052805f5260405f205f915090508054610bbf906127cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610beb906127cd565b8015610c365780601f10610c0d57610100808354040283529160200191610c36565b820191905f5260205f20905b815481529060010190602001808311610c1957829003601f168201915b505050505081565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b5f807f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166330bb3aac846005306040518463ffffffff1660e01b8152600401610ccb93929190612ae4565b602060405180830381865afa158015610ce6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d0a9190612b40565b90505f60055f8563ffffffff1663ffffffff1681526020019081526020015f208054610d35906127cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610d61906127cd565b8015610dac5780601f10610d8357610100808354040283529160200191610dac565b820191905f5260205f20905b815481529060010190602001808311610d8f57829003601f168201915b505050505090505f815103610df4576040518060400160405280601481526020017f01001101000000000000000000000000000493e000000000000000000000000081525090505b5f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663709eb66486306024866040518563ffffffff1660e01b8152600401610e559493929190612ba4565b602060405180830381865afa158015610e70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e949190612b40565b90505f8160035485610ea69190612c1b565b610eb09190612c5c565b90505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d42442213089855f6040518563ffffffff1660e01b8152600401610f129493929190612c8f565b602060405180830381865afa158015610f2d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f519190612b40565b90508082610f5f9190612c5c565b9550612710600454612710610f749190612c5c565b87610f7f9190612c1b565b610f899190612cff565b95505050505050919050565b60025481565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610fcb611241565b8060038190555050565b610fdd611f83565b610fe785836112c8565b915061762f8463ffffffff16036110e1575f6040518060e0016040528061762f63ffffffff16815260200185815260200184815260200184815260200160405180602001604052805f815250815260200160405180602001604052805f815250815260200160405180602001604052805f81525081525090508573ffffffffffffffffffffffffffffffffffffffff16633b6f743b825f6040518363ffffffff1660e01b815260040161109b929190612e3c565b6040805180830381865afa1580156110b5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110d99190612ebb565b91505061118d565b5f6110ee85858586611986565b90508573ffffffffffffffffffffffffffffffffffffffff16633b6f743b825f6040518363ffffffff1660e01b815260040161112b929190612e3c565b6040805180830381865afa158015611145573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111699190612ebb565b915061117485610c6b565b825f018181516111849190612c5c565b91508181525050505b949350505050565b61119d611241565b8060015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff166111fc610c3e565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b61124961197f565b73ffffffffffffffffffffffffffffffffffffffff16611267610c3e565b73ffffffffffffffffffffffffffffffffffffffff16146112c65761128a61197f565b6040517f118cdaa70000000000000000000000000000000000000000000000000000000081526004016112bd919061208d565b60405180910390fd5b565b5f808373ffffffffffffffffffffffffffffffffffffffff1663963efcaa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611313573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113379190612b40565b90508081846113469190612cff565b6113509190612c1b565b91505092915050565b6113d5848573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161138e93929190612ee6565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a1f565b50505050565b6114528373ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611427573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061144b9190612775565b8483611aba565b5f6040518060e0016040528061762f63ffffffff16815260200184815260200183815260200183815260200160405180602001604052805f815250815260200160405180602001604052805f815250815260200160405180602001604052805f81525081525090505f8473ffffffffffffffffffffffffffffffffffffffff16633b6f743b835f6040518363ffffffff1660e01b81526004016114f6929190612e3c565b6040805180830381865afa158015611510573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115349190612ebb565b90508473ffffffffffffffffffffffffffffffffffffffff1663c7c7f5b3825f01518484306040518563ffffffff1660e01b815260040161157793929190612f1b565b60c06040518083038185885af1158015611593573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906115b89190613043565b5050805f01513410156115f7576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f01513411156116b1575f3373ffffffffffffffffffffffffffffffffffffffff16825f0151346116299190613081565b6040516116359061274d565b5f6040518083038185875af1925050503d805f811461166f576040519150601f19603f3d011682016040523d82523d5f602084013e611674565b606091505b50509050806116af576040517ff0c49d4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5050505050565b5f6116c584848485611986565b90505f8573ffffffffffffffffffffffffffffffffffffffff16633b6f743b835f6040518363ffffffff1660e01b8152600401611703929190612e3c565b6040805180830381865afa15801561171d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117419190612ebb565b90505f61174d86610c6b565b825f015161175b9190612c5c565b905034811115611797576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61180e8773ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117e3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118079190612775565b8886611aba565b8673ffffffffffffffffffffffffffffffffffffffff1663c7c7f5b3835f01518585306040518563ffffffff1660e01b815260040161184f93929190612f1b565b60c06040518083038185885af115801561186b573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906118909190613043565b505080341115611946575f3373ffffffffffffffffffffffffffffffffffffffff1682346118be9190613081565b6040516118ca9061274d565b5f6040518083038185875af1925050503d805f8114611904576040519150601f19603f3d011682016040523d82523d5f602084013e611909565b606091505b5050905080611944576040517ff0c49d4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b50505050505050565b60015f6101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905561197c81611bc7565b50565b5f33905090565b61198e611f9b565b5f611997611c88565b90506119a8815f620f42405f611cb0565b905061762f825f019063ffffffff16908163ffffffff1681525050600254826020018181525050838260400181815250508282606001818152505080826080018190525084866040516020016119ff9291906130b4565b6040516020818303038152906040528260a0018190525050949350505050565b5f8060205f8451602086015f885af180611a3e576040513d5f823e3d81fd5b3d92505f519150505f8214611a57576001811415611a72565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b15611ab457836040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401611aab919061208d565b60405180910390fd5b50505050565b5f8373ffffffffffffffffffffffffffffffffffffffff1663095ea7b38484604051602401611aea9291906126ba565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050611b388482611d4a565b611bc157611bb6848573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3865f604051602401611b6f929190613114565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a1f565b611bc08482611a1f565b5b50505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60606003604051602001611c9c919061317c565b604051602081830303815290604052905090565b606084600361ffff16611ccc5f83611da390919063ffffffff16565b61ffff1614611d2457611ce85f82611da390919063ffffffff16565b6040517f3a51740d000000000000000000000000000000000000000000000000000000008152600401611d1b91906131a5565b60405180910390fd5b5f611d30868686611e08565b9050611d3e87600383611e78565b92505050949350505050565b5f805f8060205f8651602088015f8a5af192503d91505f519050828015611d9857505f8214611d7c5760018114611d97565b5f8673ffffffffffffffffffffffffffffffffffffffff163b115b5b935050505092915050565b5f600282611db19190612c5c565b83511015611df4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611deb90613208565b60405180910390fd5b5f8260028501015190508091505092915050565b60605f826fffffffffffffffffffffffffffffffff1614611e4c57838383604051602001611e3893929190613275565b604051602081830303815290604052611e6f565b8383604051602001611e5f9291906132b1565b6040516020818303038152906040525b90509392505050565b606083600361ffff16611e945f83611da390919063ffffffff16565b61ffff1614611eec57611eb05f82611da390919063ffffffff16565b6040517f3a51740d000000000000000000000000000000000000000000000000000000008152600401611ee391906131a5565b60405180910390fd5b84600180611efa8651611f33565b611f0491906132dc565b8686604051602001611f1a959493929190613381565b6040516020818303038152906040529150509392505050565b5f61ffff8016821115611f7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7290613447565b60405180910390fd5b819050919050565b60405180604001604052805f81526020015f81525090565b6040518060e001604052805f63ffffffff1681526020015f80191681526020015f81526020015f81526020016060815260200160608152602001606081525090565b5f604051905090565b5f80fd5b5f80fd5b5f8115159050919050565b61200281611fee565b811461200c575f80fd5b50565b5f8135905061201d81611ff9565b92915050565b5f6020828403121561203857612037611fe6565b5b5f6120458482850161200f565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6120778261204e565b9050919050565b6120878161206d565b82525050565b5f6020820190506120a05f83018461207e565b92915050565b6120af8161206d565b81146120b9575f80fd5b50565b5f813590506120ca816120a6565b92915050565b5f819050919050565b6120e2816120d0565b81146120ec575f80fd5b50565b5f813590506120fd816120d9565b92915050565b5f805f6060848603121561211a57612119611fe6565b5b5f612127868287016120bc565b9350506020612138868287016120bc565b9250506040612149868287016120ef565b9150509250925092565b61215c816120d0565b82525050565b5f6020820190506121755f830184612153565b92915050565b5f806040838503121561219157612190611fe6565b5b5f61219e858286016120bc565b92505060206121af858286016120ef565b9150509250929050565b5f63ffffffff82169050919050565b6121d1816121b9565b81146121db575f80fd5b50565b5f813590506121ec816121c8565b92915050565b5f819050919050565b612204816121f2565b811461220e575f80fd5b50565b5f8135905061221f816121fb565b92915050565b5f805f806080858703121561223d5761223c611fe6565b5b5f61224a878288016120bc565b945050602061225b878288016121de565b935050604061226c87828801612211565b925050606061227d878288016120ef565b91505092959194509250565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6122d782612291565b810181811067ffffffffffffffff821117156122f6576122f56122a1565b5b80604052505050565b5f612308611fdd565b905061231482826122ce565b919050565b5f67ffffffffffffffff821115612333576123326122a1565b5b61233c82612291565b9050602081019050919050565b828183375f83830152505050565b5f61236961236484612319565b6122ff565b9050828152602081018484840111156123855761238461228d565b5b612390848285612349565b509392505050565b5f82601f8301126123ac576123ab612289565b5b81356123bc848260208601612357565b91505092915050565b5f80604083850312156123db576123da611fe6565b5b5f6123e8858286016121de565b925050602083013567ffffffffffffffff81111561240957612408611fea565b5b61241585828601612398565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f5b8381101561245657808201518184015260208101905061243b565b5f8484015250505050565b5f61246b8261241f565b6124758185612429565b9350612485818560208601612439565b61248e81612291565b840191505092915050565b5f6020820190508181035f8301526124b18184612461565b905092915050565b5f602082840312156124ce576124cd611fe6565b5b5f6124db848285016120bc565b91505092915050565b6124ed81611fee565b82525050565b5f6020820190506125065f8301846124e4565b92915050565b5f806040838503121561252257612521611fe6565b5b5f61252f858286016120bc565b92505060206125408582860161200f565b9150509250929050565b5f6020828403121561255f5761255e611fe6565b5b5f61256c848285016120ef565b91505092915050565b5f6020828403121561258a57612589611fe6565b5b5f61259784828501612211565b91505092915050565b5f602082840312156125b5576125b4611fe6565b5b5f6125c2848285016121de565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f6125ef826125cb565b6125f981856125d5565b9350612609818560208601612439565b61261281612291565b840191505092915050565b5f6020820190508181035f83015261263581846125e5565b905092915050565b612646816121f2565b82525050565b5f60208201905061265f5f83018461263d565b92915050565b61266e816120d0565b82525050565b604082015f8201516126885f850182612665565b50602082015161269b6020850182612665565b50505050565b5f6040820190506126b45f830184612674565b92915050565b5f6040820190506126cd5f83018561207e565b6126da6020830184612153565b9392505050565b5f815190506126ef81611ff9565b92915050565b5f6020828403121561270a57612709611fe6565b5b5f612717848285016126e1565b91505092915050565b5f81905092915050565b50565b5f6127385f83612720565b91506127438261272a565b5f82019050919050565b5f6127578261272d565b9150819050919050565b5f8151905061276f816120a6565b92915050565b5f6020828403121561278a57612789611fe6565b5b5f61279784828501612761565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806127e457607f821691505b6020821081036127f7576127f66127a0565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026128597fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261281e565b612863868361281e565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61289e612899612894846120d0565b61287b565b6120d0565b9050919050565b5f819050919050565b6128b783612884565b6128cb6128c3826128a5565b84845461282a565b825550505050565b5f90565b6128df6128d3565b6128ea8184846128ae565b505050565b5b8181101561290d576129025f826128d7565b6001810190506128f0565b5050565b601f82111561295257612923816127fd565b61292c8461280f565b8101602085101561293b578190505b61294f6129478561280f565b8301826128ef565b50505b505050565b5f82821c905092915050565b5f6129725f1984600802612957565b1980831691505092915050565b5f61298a8383612963565b9150826002028217905092915050565b6129a3826125cb565b67ffffffffffffffff8111156129bc576129bb6122a1565b5b6129c682546127cd565b6129d1828285612911565b5f60209050601f831160018114612a02575f84156129f0578287015190505b6129fa858261297f565b865550612a61565b601f198416612a10866127fd565b5f5b82811015612a3757848901518255600182019150602085019450602081019050612a12565b86831015612a545784890151612a50601f891682612963565b8355505b6001600288020188555050505b505050505050565b612a72816121b9565b82525050565b5f819050919050565b5f67ffffffffffffffff82169050919050565b5f612aae612aa9612aa484612a78565b61287b565b612a81565b9050919050565b612abe81612a94565b82525050565b5f612acf5f836125d5565b9150612ada8261272a565b5f82019050919050565b5f608082019050612af75f830186612a69565b612b046020830185612ab5565b612b11604083018461207e565b8181036060830152612b2281612ac4565b9050949350505050565b5f81519050612b3a816120d9565b92915050565b5f60208284031215612b5557612b54611fe6565b5b5f612b6284828501612b2c565b91505092915050565b5f819050919050565b5f612b8e612b89612b8484612b6b565b61287b565b6120d0565b9050919050565b612b9e81612b74565b82525050565b5f608082019050612bb75f830187612a69565b612bc4602083018661207e565b612bd16040830185612b95565b8181036060830152612be381846125e5565b905095945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f612c25826120d0565b9150612c30836120d0565b9250828202612c3e816120d0565b91508282048414831517612c5557612c54612bee565b5b5092915050565b5f612c66826120d0565b9150612c71836120d0565b9250828201905080821115612c8957612c88612bee565b5b92915050565b5f608082019050612ca25f83018761207e565b612caf6020830186612a69565b612cbc6040830185612153565b612cc960608301846124e4565b95945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f612d09826120d0565b9150612d14836120d0565b925082612d2457612d23612cd2565b5b828204905092915050565b612d38816121b9565b82525050565b612d47816121f2565b82525050565b5f82825260208201905092915050565b5f612d67826125cb565b612d718185612d4d565b9350612d81818560208601612439565b612d8a81612291565b840191505092915050565b5f60e083015f830151612daa5f860182612d2f565b506020830151612dbd6020860182612d3e565b506040830151612dd06040860182612665565b506060830151612de36060860182612665565b5060808301518482036080860152612dfb8282612d5d565b91505060a083015184820360a0860152612e158282612d5d565b91505060c083015184820360c0860152612e2f8282612d5d565b9150508091505092915050565b5f6040820190508181035f830152612e548185612d95565b9050612e6360208301846124e4565b9392505050565b5f80fd5b5f60408284031215612e8357612e82612e6a565b5b612e8d60406122ff565b90505f612e9c84828501612b2c565b5f830152506020612eaf84828501612b2c565b60208301525092915050565b5f60408284031215612ed057612ecf611fe6565b5b5f612edd84828501612e6e565b91505092915050565b5f606082019050612ef95f83018661207e565b612f06602083018561207e565b612f136040830184612153565b949350505050565b5f6080820190508181035f830152612f338186612d95565b9050612f426020830185612674565b612f4f606083018461207e565b949350505050565b5f81519050612f65816121fb565b92915050565b612f7481612a81565b8114612f7e575f80fd5b50565b5f81519050612f8f81612f6b565b92915050565b5f60808284031215612faa57612fa9612e6a565b5b612fb460606122ff565b90505f612fc384828501612f57565b5f830152506020612fd684828501612f81565b6020830152506040612fea84828501612e6e565b60408301525092915050565b5f6040828403121561300b5761300a612e6a565b5b61301560406122ff565b90505f61302484828501612b2c565b5f83015250602061303784828501612b2c565b60208301525092915050565b5f8060c0838503121561305957613058611fe6565b5b5f61306685828601612f95565b925050608061307785828601612ff6565b9150509250929050565b5f61308b826120d0565b9150613096836120d0565b92508282039050818111156130ae576130ad612bee565b5b92915050565b5f6040820190506130c75f83018561263d565b6130d46020830184612a69565b9392505050565b5f819050919050565b5f6130fe6130f96130f4846130db565b61287b565b6120d0565b9050919050565b61310e816130e4565b82525050565b5f6040820190506131275f83018561207e565b6131346020830184613105565b9392505050565b5f61ffff82169050919050565b5f8160f01b9050919050565b5f61315e82613148565b9050919050565b6131766131718261313b565b613154565b82525050565b5f6131878284613165565b60028201915081905092915050565b61319f8161313b565b82525050565b5f6020820190506131b85f830184613196565b92915050565b7f746f55696e7431365f6f75744f66426f756e64730000000000000000000000005f82015250565b5f6131f2601483612429565b91506131fd826131be565b602082019050919050565b5f6020820190508181035f83015261321f816131e6565b9050919050565b5f6fffffffffffffffffffffffffffffffff82169050919050565b5f8160801b9050919050565b5f61325782613241565b9050919050565b61326f61326a82613226565b61324d565b82525050565b5f6132808286613165565b600282019150613290828561325e565b6010820191506132a0828461325e565b601082019150819050949350505050565b5f6132bc8285613165565b6002820191506132cc828461325e565b6010820191508190509392505050565b5f6132e68261313b565b91506132f18361313b565b9250828201905061ffff81111561330b5761330a612bee565b5b92915050565b5f61331b826125cb565b6133258185612720565b9350613335818560208601612439565b80840191505092915050565b5f60ff82169050919050565b5f8160f81b9050919050565b5f6133638261334d565b9050919050565b61337b61337682613341565b613359565b82525050565b5f61338c8288613311565b9150613398828761336a565b6001820191506133a88286613165565b6002820191506133b8828561336a565b6001820191506133c88284613311565b91508190509695505050505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20315f8201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b5f613431602683612429565b915061343c826133d7565b604082019050919050565b5f6020820190508181035f83015261345e81613425565b90509190505600000000000000000000000047ff5bbab981ff022743aa4281d4d6dd7fb1a4d00000000000000000000000002a2019b30c157db6c1c01306b8025167dbe1803b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000004208d6e27538189bb48e603d6123a94b8abe0a0b000000000000000000000000282b3386571f7f794450d5789911a9804fa346b40000000000000000000000004514fc667a944752ee8a29f544c1b20b1a315f25000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000000600000000000000000000000058e3ee6accd124642ddb5d3f91928816be8d8ed3000000000000000000000000137643f7b2c189173867b3391f6629cab46f0f1a000000000000000000000000288f9d76019469bfeb56bb77d86afa2bf563b75b0000000000000000000000003b4cf37a3335f21c945a40088404c715525fcb2900000000000000000000000029acc7c504665a5ea95344796f784095f0cfcc58000000000000000000000000ba554f7a47f0792b9fa41a1256d4cf628bb1d028000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000075d80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240100210100000000000000000000000000030d40000000000000000000000000002dc6c000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x60806040526004361061019f575f3560e01c8063630dc7cb116100eb578063b218b19811610089578063e30c397811610063578063e30c397814610560578063ec1278d61461058a578063efb79985146105b2578063f2fde38b146105ee576101a6565b8063b218b198146104d0578063c616f376146104fa578063d393f07214610536576101a6565b806377958f87116100c557806377958f871461042c57806379ba5097146104545780638153924b1461046a5780638da5cb5b146104a6576101a6565b8063630dc7cb146103c457806367fb4738146103ee578063715018a614610416576101a6565b80633e832c901161015857806359c7c5161161013257806359c7c5161461030e5780635b461c831461034a5780635c975abb146103725780635e8c18da1461039c576101a6565b80633e832c90146102a05780635135db46146102bc57806354fd4d50146102e4576101a6565b806302329a29146101aa578063104db380146101d25780631171bda9146101fc57806324df604b146102245780632d2c55651461024e5780633e0c062914610278576101a6565b366101a657005b5f80fd5b3480156101b5575f80fd5b506101d060048036038101906101cb9190612023565b610616565b005b3480156101dd575f80fd5b506101e661063b565b6040516101f3919061208d565b60405180910390f35b348015610207575f80fd5b50610222600480360381019061021d9190612103565b61065f565b005b34801561022f575f80fd5b506102386106e8565b6040516102459190612162565b60405180910390f35b348015610259575f80fd5b506102626106ee565b60405161026f919061208d565b60405180910390f35b348015610283575f80fd5b5061029e6004803603810190610299919061217b565b610712565b005b6102ba60048036038101906102b59190612225565b610784565b005b3480156102c7575f80fd5b506102e260048036038101906102dd91906123c5565b610992565b005b3480156102ef575f80fd5b506102f86109c9565b6040516103059190612499565b60405180910390f35b348015610319575f80fd5b50610334600480360381019061032f91906124b9565b610a06565b60405161034191906124f3565b60405180910390f35b348015610355575f80fd5b50610370600480360381019061036b91906124b9565b610a23565b005b34801561037d575f80fd5b50610386610a47565b60405161039391906124f3565b60405180910390f35b3480156103a7575f80fd5b506103c260048036038101906103bd919061250c565b610a5a565b005b3480156103cf575f80fd5b506103d8610aba565b6040516103e5919061208d565b60405180910390f35b3480156103f9575f80fd5b50610414600480360381019061040f919061254a565b610ade565b005b348015610421575f80fd5b5061042a610af0565b005b348015610437575f80fd5b50610452600480360381019061044d9190612575565b610b03565b005b34801561045f575f80fd5b50610468610b15565b005b348015610475575f80fd5b50610490600480360381019061048b91906125a0565b610ba3565b60405161049d919061261d565b60405180910390f35b3480156104b1575f80fd5b506104ba610c3e565b6040516104c7919061208d565b60405180910390f35b3480156104db575f80fd5b506104e4610c65565b6040516104f19190612162565b60405180910390f35b348015610505575f80fd5b50610520600480360381019061051b91906125a0565b610c6b565b60405161052d9190612162565b60405180910390f35b348015610541575f80fd5b5061054a610f95565b604051610557919061264c565b60405180910390f35b34801561056b575f80fd5b50610574610f9b565b604051610581919061208d565b60405180910390f35b348015610595575f80fd5b506105b060048036038101906105ab919061254a565b610fc3565b005b3480156105bd575f80fd5b506105d860048036038101906105d39190612225565b610fd5565b6040516105e591906126a1565b60405180910390f35b3480156105f9575f80fd5b50610614600480360381019061060f91906124b9565b611195565b005b61061e611241565b80600160146101000a81548160ff02191690831515021790555050565b7f000000000000000000000000282b3386571f7f794450d5789911a9804fa346b481565b610667611241565b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83836040518363ffffffff1660e01b81526004016106a29291906126ba565b6020604051808303815f875af11580156106be573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106e291906126f5565b50505050565b60045481565b7f0000000000000000000000004514fc667a944752ee8a29f544c1b20b1a315f2581565b61071a611241565b8173ffffffffffffffffffffffffffffffffffffffff168160405161073e9061274d565b5f6040518083038185875af1925050503d805f8114610778576040519150601f19603f3d011682016040523d82523d5f602084013e61077d565b606091505b5050505050565b600160149054906101000a900460ff16156107cb576040517f819f993900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1661084b576040517f7413e48600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61085584826112c8565b90505f8103610890576040517f4fdf5da600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6109088473ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109009190612775565b333084611359565b61762f8363ffffffff1603610927576109228483836113db565b610934565b610933848484846116b8565b5b818363ffffffff163373ffffffffffffffffffffffffffffffffffffffff167fbc9ee36b6ca0bdd5b3840e6d329dd19a2490d880c7ce24d9818aa593adfb35be87856040516109849291906126ba565b60405180910390a450505050565b61099a611241565b8060055f8463ffffffff1663ffffffff1681526020019081526020015f2090816109c4919061299a565b505050565b60606040518060400160405280600581526020017f312e302e31000000000000000000000000000000000000000000000000000000815250905090565b6006602052805f5260405f205f915054906101000a900460ff1681565b610a448173ffffffffffffffffffffffffffffffffffffffff165f1b610b03565b50565b600160149054906101000a900460ff1681565b610a62611241565b8060065f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055505050565b7f0000000000000000000000004208d6e27538189bb48e603d6123a94b8abe0a0b81565b610ae6611241565b8060048190555050565b610af8611241565b610b015f61194f565b565b610b0b611241565b8060028190555050565b5f610b1e61197f565b90508073ffffffffffffffffffffffffffffffffffffffff16610b3f610f9b565b73ffffffffffffffffffffffffffffffffffffffff1614610b9757806040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610b8e919061208d565b60405180910390fd5b610ba08161194f565b50565b6005602052805f5260405f205f915090508054610bbf906127cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610beb906127cd565b8015610c365780601f10610c0d57610100808354040283529160200191610c36565b820191905f5260205f20905b815481529060010190602001808311610c1957829003601f168201915b505050505081565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60035481565b5f807f000000000000000000000000282b3386571f7f794450d5789911a9804fa346b473ffffffffffffffffffffffffffffffffffffffff166330bb3aac846005306040518463ffffffff1660e01b8152600401610ccb93929190612ae4565b602060405180830381865afa158015610ce6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d0a9190612b40565b90505f60055f8563ffffffff1663ffffffff1681526020019081526020015f208054610d35906127cd565b80601f0160208091040260200160405190810160405280929190818152602001828054610d61906127cd565b8015610dac5780601f10610d8357610100808354040283529160200191610dac565b820191905f5260205f20905b815481529060010190602001808311610d8f57829003601f168201915b505050505090505f815103610df4576040518060400160405280601481526020017f01001101000000000000000000000000000493e000000000000000000000000081525090505b5f7f0000000000000000000000004208d6e27538189bb48e603d6123a94b8abe0a0b73ffffffffffffffffffffffffffffffffffffffff1663709eb66486306024866040518563ffffffff1660e01b8152600401610e559493929190612ba4565b602060405180830381865afa158015610e70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e949190612b40565b90505f8160035485610ea69190612c1b565b610eb09190612c5c565b90505f7f0000000000000000000000004514fc667a944752ee8a29f544c1b20b1a315f2573ffffffffffffffffffffffffffffffffffffffff1663d42442213089855f6040518563ffffffff1660e01b8152600401610f129493929190612c8f565b602060405180830381865afa158015610f2d573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f519190612b40565b90508082610f5f9190612c5c565b9550612710600454612710610f749190612c5c565b87610f7f9190612c1b565b610f899190612cff565b95505050505050919050565b60025481565b5f60015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b610fcb611241565b8060038190555050565b610fdd611f83565b610fe785836112c8565b915061762f8463ffffffff16036110e1575f6040518060e0016040528061762f63ffffffff16815260200185815260200184815260200184815260200160405180602001604052805f815250815260200160405180602001604052805f815250815260200160405180602001604052805f81525081525090508573ffffffffffffffffffffffffffffffffffffffff16633b6f743b825f6040518363ffffffff1660e01b815260040161109b929190612e3c565b6040805180830381865afa1580156110b5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110d99190612ebb565b91505061118d565b5f6110ee85858586611986565b90508573ffffffffffffffffffffffffffffffffffffffff16633b6f743b825f6040518363ffffffff1660e01b815260040161112b929190612e3c565b6040805180830381865afa158015611145573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111699190612ebb565b915061117485610c6b565b825f018181516111849190612c5c565b91508181525050505b949350505050565b61119d611241565b8060015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff166111fc610c3e565b73ffffffffffffffffffffffffffffffffffffffff167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b61124961197f565b73ffffffffffffffffffffffffffffffffffffffff16611267610c3e565b73ffffffffffffffffffffffffffffffffffffffff16146112c65761128a61197f565b6040517f118cdaa70000000000000000000000000000000000000000000000000000000081526004016112bd919061208d565b60405180910390fd5b565b5f808373ffffffffffffffffffffffffffffffffffffffff1663963efcaa6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611313573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113379190612b40565b90508081846113469190612cff565b6113509190612c1b565b91505092915050565b6113d5848573ffffffffffffffffffffffffffffffffffffffff166323b872dd86868660405160240161138e93929190612ee6565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a1f565b50505050565b6114528373ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611427573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061144b9190612775565b8483611aba565b5f6040518060e0016040528061762f63ffffffff16815260200184815260200183815260200183815260200160405180602001604052805f815250815260200160405180602001604052805f815250815260200160405180602001604052805f81525081525090505f8473ffffffffffffffffffffffffffffffffffffffff16633b6f743b835f6040518363ffffffff1660e01b81526004016114f6929190612e3c565b6040805180830381865afa158015611510573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115349190612ebb565b90508473ffffffffffffffffffffffffffffffffffffffff1663c7c7f5b3825f01518484306040518563ffffffff1660e01b815260040161157793929190612f1b565b60c06040518083038185885af1158015611593573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906115b89190613043565b5050805f01513410156115f7576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f01513411156116b1575f3373ffffffffffffffffffffffffffffffffffffffff16825f0151346116299190613081565b6040516116359061274d565b5f6040518083038185875af1925050503d805f811461166f576040519150601f19603f3d011682016040523d82523d5f602084013e611674565b606091505b50509050806116af576040517ff0c49d4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b5050505050565b5f6116c584848485611986565b90505f8573ffffffffffffffffffffffffffffffffffffffff16633b6f743b835f6040518363ffffffff1660e01b8152600401611703929190612e3c565b6040805180830381865afa15801561171d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117419190612ebb565b90505f61174d86610c6b565b825f015161175b9190612c5c565b905034811115611797576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61180e8773ffffffffffffffffffffffffffffffffffffffff1663fc0c546a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117e3573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118079190612775565b8886611aba565b8673ffffffffffffffffffffffffffffffffffffffff1663c7c7f5b3835f01518585306040518563ffffffff1660e01b815260040161184f93929190612f1b565b60c06040518083038185885af115801561186b573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906118909190613043565b505080341115611946575f3373ffffffffffffffffffffffffffffffffffffffff1682346118be9190613081565b6040516118ca9061274d565b5f6040518083038185875af1925050503d805f8114611904576040519150601f19603f3d011682016040523d82523d5f602084013e611909565b606091505b5050905080611944576040517ff0c49d4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b50505050505050565b60015f6101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905561197c81611bc7565b50565b5f33905090565b61198e611f9b565b5f611997611c88565b90506119a8815f620f42405f611cb0565b905061762f825f019063ffffffff16908163ffffffff1681525050600254826020018181525050838260400181815250508282606001818152505080826080018190525084866040516020016119ff9291906130b4565b6040516020818303038152906040528260a0018190525050949350505050565b5f8060205f8451602086015f885af180611a3e576040513d5f823e3d81fd5b3d92505f519150505f8214611a57576001811415611a72565b5f8473ffffffffffffffffffffffffffffffffffffffff163b145b15611ab457836040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401611aab919061208d565b60405180910390fd5b50505050565b5f8373ffffffffffffffffffffffffffffffffffffffff1663095ea7b38484604051602401611aea9291906126ba565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050611b388482611d4a565b611bc157611bb6848573ffffffffffffffffffffffffffffffffffffffff1663095ea7b3865f604051602401611b6f929190613114565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611a1f565b611bc08482611a1f565b5b50505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b60606003604051602001611c9c919061317c565b604051602081830303815290604052905090565b606084600361ffff16611ccc5f83611da390919063ffffffff16565b61ffff1614611d2457611ce85f82611da390919063ffffffff16565b6040517f3a51740d000000000000000000000000000000000000000000000000000000008152600401611d1b91906131a5565b60405180910390fd5b5f611d30868686611e08565b9050611d3e87600383611e78565b92505050949350505050565b5f805f8060205f8651602088015f8a5af192503d91505f519050828015611d9857505f8214611d7c5760018114611d97565b5f8673ffffffffffffffffffffffffffffffffffffffff163b115b5b935050505092915050565b5f600282611db19190612c5c565b83511015611df4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611deb90613208565b60405180910390fd5b5f8260028501015190508091505092915050565b60605f826fffffffffffffffffffffffffffffffff1614611e4c57838383604051602001611e3893929190613275565b604051602081830303815290604052611e6f565b8383604051602001611e5f9291906132b1565b6040516020818303038152906040525b90509392505050565b606083600361ffff16611e945f83611da390919063ffffffff16565b61ffff1614611eec57611eb05f82611da390919063ffffffff16565b6040517f3a51740d000000000000000000000000000000000000000000000000000000008152600401611ee391906131a5565b60405180910390fd5b84600180611efa8651611f33565b611f0491906132dc565b8686604051602001611f1a959493929190613381565b6040516020818303038152906040529150509392505050565b5f61ffff8016821115611f7b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f7290613447565b60405180910390fd5b819050919050565b60405180604001604052805f81526020015f81525090565b6040518060e001604052805f63ffffffff1681526020015f80191681526020015f81526020015f81526020016060815260200160608152602001606081525090565b5f604051905090565b5f80fd5b5f80fd5b5f8115159050919050565b61200281611fee565b811461200c575f80fd5b50565b5f8135905061201d81611ff9565b92915050565b5f6020828403121561203857612037611fe6565b5b5f6120458482850161200f565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6120778261204e565b9050919050565b6120878161206d565b82525050565b5f6020820190506120a05f83018461207e565b92915050565b6120af8161206d565b81146120b9575f80fd5b50565b5f813590506120ca816120a6565b92915050565b5f819050919050565b6120e2816120d0565b81146120ec575f80fd5b50565b5f813590506120fd816120d9565b92915050565b5f805f6060848603121561211a57612119611fe6565b5b5f612127868287016120bc565b9350506020612138868287016120bc565b9250506040612149868287016120ef565b9150509250925092565b61215c816120d0565b82525050565b5f6020820190506121755f830184612153565b92915050565b5f806040838503121561219157612190611fe6565b5b5f61219e858286016120bc565b92505060206121af858286016120ef565b9150509250929050565b5f63ffffffff82169050919050565b6121d1816121b9565b81146121db575f80fd5b50565b5f813590506121ec816121c8565b92915050565b5f819050919050565b612204816121f2565b811461220e575f80fd5b50565b5f8135905061221f816121fb565b92915050565b5f805f806080858703121561223d5761223c611fe6565b5b5f61224a878288016120bc565b945050602061225b878288016121de565b935050604061226c87828801612211565b925050606061227d878288016120ef565b91505092959194509250565b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6122d782612291565b810181811067ffffffffffffffff821117156122f6576122f56122a1565b5b80604052505050565b5f612308611fdd565b905061231482826122ce565b919050565b5f67ffffffffffffffff821115612333576123326122a1565b5b61233c82612291565b9050602081019050919050565b828183375f83830152505050565b5f61236961236484612319565b6122ff565b9050828152602081018484840111156123855761238461228d565b5b612390848285612349565b509392505050565b5f82601f8301126123ac576123ab612289565b5b81356123bc848260208601612357565b91505092915050565b5f80604083850312156123db576123da611fe6565b5b5f6123e8858286016121de565b925050602083013567ffffffffffffffff81111561240957612408611fea565b5b61241585828601612398565b9150509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f5b8381101561245657808201518184015260208101905061243b565b5f8484015250505050565b5f61246b8261241f565b6124758185612429565b9350612485818560208601612439565b61248e81612291565b840191505092915050565b5f6020820190508181035f8301526124b18184612461565b905092915050565b5f602082840312156124ce576124cd611fe6565b5b5f6124db848285016120bc565b91505092915050565b6124ed81611fee565b82525050565b5f6020820190506125065f8301846124e4565b92915050565b5f806040838503121561252257612521611fe6565b5b5f61252f858286016120bc565b92505060206125408582860161200f565b9150509250929050565b5f6020828403121561255f5761255e611fe6565b5b5f61256c848285016120ef565b91505092915050565b5f6020828403121561258a57612589611fe6565b5b5f61259784828501612211565b91505092915050565b5f602082840312156125b5576125b4611fe6565b5b5f6125c2848285016121de565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f6125ef826125cb565b6125f981856125d5565b9350612609818560208601612439565b61261281612291565b840191505092915050565b5f6020820190508181035f83015261263581846125e5565b905092915050565b612646816121f2565b82525050565b5f60208201905061265f5f83018461263d565b92915050565b61266e816120d0565b82525050565b604082015f8201516126885f850182612665565b50602082015161269b6020850182612665565b50505050565b5f6040820190506126b45f830184612674565b92915050565b5f6040820190506126cd5f83018561207e565b6126da6020830184612153565b9392505050565b5f815190506126ef81611ff9565b92915050565b5f6020828403121561270a57612709611fe6565b5b5f612717848285016126e1565b91505092915050565b5f81905092915050565b50565b5f6127385f83612720565b91506127438261272a565b5f82019050919050565b5f6127578261272d565b9150819050919050565b5f8151905061276f816120a6565b92915050565b5f6020828403121561278a57612789611fe6565b5b5f61279784828501612761565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806127e457607f821691505b6020821081036127f7576127f66127a0565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026128597fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261281e565b612863868361281e565b95508019841693508086168417925050509392505050565b5f819050919050565b5f61289e612899612894846120d0565b61287b565b6120d0565b9050919050565b5f819050919050565b6128b783612884565b6128cb6128c3826128a5565b84845461282a565b825550505050565b5f90565b6128df6128d3565b6128ea8184846128ae565b505050565b5b8181101561290d576129025f826128d7565b6001810190506128f0565b5050565b601f82111561295257612923816127fd565b61292c8461280f565b8101602085101561293b578190505b61294f6129478561280f565b8301826128ef565b50505b505050565b5f82821c905092915050565b5f6129725f1984600802612957565b1980831691505092915050565b5f61298a8383612963565b9150826002028217905092915050565b6129a3826125cb565b67ffffffffffffffff8111156129bc576129bb6122a1565b5b6129c682546127cd565b6129d1828285612911565b5f60209050601f831160018114612a02575f84156129f0578287015190505b6129fa858261297f565b865550612a61565b601f198416612a10866127fd565b5f5b82811015612a3757848901518255600182019150602085019450602081019050612a12565b86831015612a545784890151612a50601f891682612963565b8355505b6001600288020188555050505b505050505050565b612a72816121b9565b82525050565b5f819050919050565b5f67ffffffffffffffff82169050919050565b5f612aae612aa9612aa484612a78565b61287b565b612a81565b9050919050565b612abe81612a94565b82525050565b5f612acf5f836125d5565b9150612ada8261272a565b5f82019050919050565b5f608082019050612af75f830186612a69565b612b046020830185612ab5565b612b11604083018461207e565b8181036060830152612b2281612ac4565b9050949350505050565b5f81519050612b3a816120d9565b92915050565b5f60208284031215612b5557612b54611fe6565b5b5f612b6284828501612b2c565b91505092915050565b5f819050919050565b5f612b8e612b89612b8484612b6b565b61287b565b6120d0565b9050919050565b612b9e81612b74565b82525050565b5f608082019050612bb75f830187612a69565b612bc4602083018661207e565b612bd16040830185612b95565b8181036060830152612be381846125e5565b905095945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f612c25826120d0565b9150612c30836120d0565b9250828202612c3e816120d0565b91508282048414831517612c5557612c54612bee565b5b5092915050565b5f612c66826120d0565b9150612c71836120d0565b9250828201905080821115612c8957612c88612bee565b5b92915050565b5f608082019050612ca25f83018761207e565b612caf6020830186612a69565b612cbc6040830185612153565b612cc960608301846124e4565b95945050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f612d09826120d0565b9150612d14836120d0565b925082612d2457612d23612cd2565b5b828204905092915050565b612d38816121b9565b82525050565b612d47816121f2565b82525050565b5f82825260208201905092915050565b5f612d67826125cb565b612d718185612d4d565b9350612d81818560208601612439565b612d8a81612291565b840191505092915050565b5f60e083015f830151612daa5f860182612d2f565b506020830151612dbd6020860182612d3e565b506040830151612dd06040860182612665565b506060830151612de36060860182612665565b5060808301518482036080860152612dfb8282612d5d565b91505060a083015184820360a0860152612e158282612d5d565b91505060c083015184820360c0860152612e2f8282612d5d565b9150508091505092915050565b5f6040820190508181035f830152612e548185612d95565b9050612e6360208301846124e4565b9392505050565b5f80fd5b5f60408284031215612e8357612e82612e6a565b5b612e8d60406122ff565b90505f612e9c84828501612b2c565b5f830152506020612eaf84828501612b2c565b60208301525092915050565b5f60408284031215612ed057612ecf611fe6565b5b5f612edd84828501612e6e565b91505092915050565b5f606082019050612ef95f83018661207e565b612f06602083018561207e565b612f136040830184612153565b949350505050565b5f6080820190508181035f830152612f338186612d95565b9050612f426020830185612674565b612f4f606083018461207e565b949350505050565b5f81519050612f65816121fb565b92915050565b612f7481612a81565b8114612f7e575f80fd5b50565b5f81519050612f8f81612f6b565b92915050565b5f60808284031215612faa57612fa9612e6a565b5b612fb460606122ff565b90505f612fc384828501612f57565b5f830152506020612fd684828501612f81565b6020830152506040612fea84828501612e6e565b60408301525092915050565b5f6040828403121561300b5761300a612e6a565b5b61301560406122ff565b90505f61302484828501612b2c565b5f83015250602061303784828501612b2c565b60208301525092915050565b5f8060c0838503121561305957613058611fe6565b5b5f61306685828601612f95565b925050608061307785828601612ff6565b9150509250929050565b5f61308b826120d0565b9150613096836120d0565b92508282039050818111156130ae576130ad612bee565b5b92915050565b5f6040820190506130c75f83018561263d565b6130d46020830184612a69565b9392505050565b5f819050919050565b5f6130fe6130f96130f4846130db565b61287b565b6120d0565b9050919050565b61310e816130e4565b82525050565b5f6040820190506131275f83018561207e565b6131346020830184613105565b9392505050565b5f61ffff82169050919050565b5f8160f01b9050919050565b5f61315e82613148565b9050919050565b6131766131718261313b565b613154565b82525050565b5f6131878284613165565b60028201915081905092915050565b61319f8161313b565b82525050565b5f6020820190506131b85f830184613196565b92915050565b7f746f55696e7431365f6f75744f66426f756e64730000000000000000000000005f82015250565b5f6131f2601483612429565b91506131fd826131be565b602082019050919050565b5f6020820190508181035f83015261321f816131e6565b9050919050565b5f6fffffffffffffffffffffffffffffffff82169050919050565b5f8160801b9050919050565b5f61325782613241565b9050919050565b61326f61326a82613226565b61324d565b82525050565b5f6132808286613165565b600282019150613290828561325e565b6010820191506132a0828461325e565b601082019150819050949350505050565b5f6132bc8285613165565b6002820191506132cc828461325e565b6010820191508190509392505050565b5f6132e68261313b565b91506132f18361313b565b9250828201905061ffff81111561330b5761330a612bee565b5b92915050565b5f61331b826125cb565b6133258185612720565b9350613335818560208601612439565b80840191505092915050565b5f60ff82169050919050565b5f8160f81b9050919050565b5f6133638261334d565b9050919050565b61337b61337682613341565b613359565b82525050565b5f61338c8288613311565b9150613398828761336a565b6001820191506133a88286613165565b6002820191506133b8828561336a565b6001820191506133c88284613311565b91508190509695505050505050565b7f53616665436173743a2076616c756520646f65736e27742066697420696e20315f8201527f3620626974730000000000000000000000000000000000000000000000000000602082015250565b5f613431602683612429565b915061343c826133d7565b604082019050919050565b5f6020820190508181035f83015261345e81613425565b905091905056
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000047ff5bbab981ff022743aa4281d4d6dd7fb1a4d00000000000000000000000002a2019b30c157db6c1c01306b8025167dbe1803b00000000000000000000000000000000000000000000000000000000000000030000000000000000000000004208d6e27538189bb48e603d6123a94b8abe0a0b000000000000000000000000282b3386571f7f794450d5789911a9804fa346b40000000000000000000000004514fc667a944752ee8a29f544c1b20b1a315f25000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240000000000000000000000000000000000000000000000000000000000000000600000000000000000000000058e3ee6accd124642ddb5d3f91928816be8d8ed3000000000000000000000000137643f7b2c189173867b3391f6629cab46f0f1a000000000000000000000000288f9d76019469bfeb56bb77d86afa2bf563b75b0000000000000000000000003b4cf37a3335f21c945a40088404c715525fcb2900000000000000000000000029acc7c504665a5ea95344796f784095f0cfcc58000000000000000000000000ba554f7a47f0792b9fa41a1256d4cf628bb1d028000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000075d80000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000240100210100000000000000000000000000030d40000000000000000000000000002dc6c000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _owner (address): 0x47FF5bBAB981Ff022743AA4281D4d6Dd7Fb1a4D0
Arg [1] : _fraxtalHop (bytes32): 0x0000000000000000000000002a2019b30c157db6c1c01306b8025167dbe1803b
Arg [2] : _numDVNs (uint256): 3
Arg [3] : _EXECUTOR (address): 0x4208D6E27538189bB48E603D6123A94b8Abe0A0b
Arg [4] : _DVN (address): 0x282b3386571f7f794450d5789911a9804FA346b4
Arg [5] : _TREASURY (address): 0x4514FC667a944752ee8A29F544c1B20b1A315f25
Arg [6] : _approvedOfts (address[]): 0x58E3ee6accd124642dDB5d3f91928816Be8D8ed3,0x137643F7b2C189173867b3391f6629caB46F0F1a,0x288F9D76019469bfEb56BB77d86aFa2bF563B75B,0x3B4cf37A3335F21c945a40088404c715525fCb29,0x29aCC7c504665A5EA95344796f784095f0cfcC58,0xBa554F7A47f0792b9fa41A1256d4cf628Bb1D028
Arg [7] : _eids (uint32[]): 30168
Arg [8] : _executorOptions (bytes[]): System.Byte[]
-----Encoded View---------------
23 Constructor Arguments found :
Arg [0] : 00000000000000000000000047ff5bbab981ff022743aa4281d4d6dd7fb1a4d0
Arg [1] : 0000000000000000000000002a2019b30c157db6c1c01306b8025167dbe1803b
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [3] : 0000000000000000000000004208d6e27538189bb48e603d6123a94b8abe0a0b
Arg [4] : 000000000000000000000000282b3386571f7f794450d5789911a9804fa346b4
Arg [5] : 0000000000000000000000004514fc667a944752ee8a29f544c1b20b1a315f25
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000240
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [10] : 00000000000000000000000058e3ee6accd124642ddb5d3f91928816be8d8ed3
Arg [11] : 000000000000000000000000137643f7b2c189173867b3391f6629cab46f0f1a
Arg [12] : 000000000000000000000000288f9d76019469bfeb56bb77d86afa2bf563b75b
Arg [13] : 0000000000000000000000003b4cf37a3335f21c945a40088404c715525fcb29
Arg [14] : 00000000000000000000000029acc7c504665a5ea95344796f784095f0cfcc58
Arg [15] : 000000000000000000000000ba554f7a47f0792b9fa41a1256d4cf628bb1d028
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [17] : 00000000000000000000000000000000000000000000000000000000000075d8
Arg [18] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [20] : 0000000000000000000000000000000000000000000000000000000000000024
Arg [21] : 0100210100000000000000000000000000030d40000000000000000000000000
Arg [22] : 002dc6c000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.04
Net Worth in MON
Token Allocations
MON
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| MONAD | 100.00% | $0.018326 | 2.2264 | $0.040801 |
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.