Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
Vault
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity =0.8.21;
import {UUPSUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
import {BaseAppUpgradeable} from "src/base/BaseAppUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title Vault
* @dev A contract for managing token operations with upgradeable functionality and cross-chain capabilities.
*/
contract Vault is UUPSUpgradeable, BaseAppUpgradeable {
using SafeERC20 for IERC20;
uint16 immutable dstChainId;
/// @custom:storage-location erc7201:real.storage.Vault
struct VaultStorage {
// srcToken => dstToken
mapping(address => address) tokenPairs;
}
// keccak256(abi.encode(uint256(keccak256("real.storage.Vault")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant VaultStorageLocation = 0xb6416d507a04e2a32445de45abf7290bf3bbe8e9fa76203447827b6ceacc5300;
event UpdateTokenPairs(address indexed srcToken, address indexed dstToken);
function _getVaultStorage() private pure returns (VaultStorage storage $) {
// slither-disable-next-line assembly
assembly {
$.slot := VaultStorageLocation
}
}
/**
* @param endpoint_ The endpoint for Layer Zero operations.
* @param dstChainId_ The chain id of the controller.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor(address endpoint_, uint16 dstChainId_) BaseAppUpgradeable(endpoint_) {
dstChainId = dstChainId_;
}
/**
* @notice Initializes the vault with the initial owner.
* @param initialOwner The admin address.
*/
function initialize(address initialOwner) external initializer {
__UUPSUpgradeable_init();
__BaseApp_init(initialOwner);
}
/**
* @dev The Vault can only be upgraded by the owner
* @param v new Vault implementation
*/
function _authorizeUpgrade(address v) internal override onlyOwner {}
/**
* @notice Adds a token pair to the whitelist and updates the token pairs mapping.
* @param srcToken The address of the source token.
* @param dstToken The address of the destination token.
* @dev Only callable by the owner. Reverts if either token address is zero.
*/
function setWhitelistToken(address srcToken, address dstToken) external onlyOwner {
if (srcToken == address(0) || dstToken == address(0)) revert ZeroAddress();
_updateWhitelistToken(srcToken, true);
VaultStorage storage $ = _getVaultStorage();
$.tokenPairs[srcToken] = dstToken;
$.tokenPairs[dstToken] = srcToken;
emit UpdateTokenPairs(srcToken, dstToken);
}
/**
* @notice Removes a token from the whitelist and updates the token pairs mapping.
* @param srcToken The address of the source token to remove.
* @dev Only callable by the owner. Reverts if the token address is zero.
*/
function removeWhitelistToken(address srcToken) external onlyOwner {
if (srcToken == address(0)) revert ZeroAddress();
_updateWhitelistToken(srcToken, false);
VaultStorage storage $ = _getVaultStorage();
address dstToken = $.tokenPairs[srcToken];
$.tokenPairs[srcToken] = address(0);
$.tokenPairs[dstToken] = address(0);
emit UpdateTokenPairs(srcToken, address(0));
}
// ==================== INTERNAL ====================
/**
* @dev Internal function to handle token sending across chains.
*
* @param srcToken The address of the source token.
* @param amount The amount of the token to send.
* @param _adapterParams Adapter parameters for the Layer Zero send function.
*/
function _send(uint16, address srcToken, uint256 amount, bytes memory _adapterParams) internal override {
amount = _safeTransferFrom(srcToken, _msgSender(), address(this), amount);
if (amount == 0) revert InvalidAmount();
VaultStorage storage $ = _getVaultStorage();
address _mainChainToken = $.tokenPairs[srcToken];
bytes memory _payload = abi.encode(_mainChainToken, _msgSender(), amount);
_lzSend(dstChainId, _payload, payable(_msgSender()), address(0x0), _adapterParams, msg.value);
}
/**
* @dev Internal function to handle token receiving.
* @param mainChainToken The address of the main chain token burned.
* @param recipient The address of the recipient.
* @param amount The amount of the token received.
* @return The address of the source token.
*/
function _receive(address mainChainToken, address recipient, uint256 amount) internal override returns (address) {
VaultStorage storage $ = _getVaultStorage();
address srcToken = $.tokenPairs[mainChainToken];
if (srcToken == address(0) || !isWhitelistedToken(srcToken)) revert TokenNotAllowed();
IERC20(srcToken).safeTransfer(recipient, amount);
return srcToken;
}
/**
* @dev Internal function to get the main chain token address from the source token address.
* @param srcToken The address of the source token.
* @return mainChainToken The address of the main chain token.
*/
function _getMainChainToken(address srcToken) internal view override returns (address mainChainToken) {
VaultStorage storage $ = _getVaultStorage();
mainChainToken = $.tokenPairs[srcToken];
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.20;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC1967-compliant implementation pointing to self.
* See {_onlyProxy}.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity =0.8.21;
import {ReentrancyGuardUpgradeable} from
"openzeppelin-contracts-upgradeable/contracts/utils/ReentrancyGuardUpgradeable.sol";
import {OwnableUpgradeable} from "openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol";
import {NonblockingLzAppUpgradeable} from "@tangible/layerzero/lzApp/NonblockingLzAppUpgradeable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
/**
* @title BaseAppUpgradeable
* @dev A base contract for managing token operations with upgradeable functionality, cross-chain capabilities, and security features.
*/
abstract contract BaseAppUpgradeable is ReentrancyGuardUpgradeable, OwnableUpgradeable, NonblockingLzAppUpgradeable {
using SafeERC20 for IERC20;
/// @custom:storage-location erc7201:real.storage.BaseApp
struct BaseAppStorage {
bool paused;
bytes defaultAdapterParams;
mapping(address => bool) whitelisted;
mapping(address => address) tokenPairs; // srcToken => dstToken
}
// keccak256(abi.encode(uint256(keccak256("real.storage.BaseApp")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant BaseAppStorageLocation = 0x3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac216000;
event Paused(bool isPaused);
event Whitelisted(address indexed token, bool isWhitelisted);
event BridgeToken(address indexed token, uint256 amount);
event TokenClaimed(uint16 indexed srcId, address indexed token, address indexed receiver, uint256 amount);
event TokenRescued(address indexed token, address indexed receiver, uint256 amount);
event UpdateLzAdapterParams(uint256 limit);
error ZeroAddress();
error TokenNotAllowed();
error IsPaused();
error InvalidParam();
error InvalidAmount();
error NotAuthorized();
function _getBaseAppStorage() private pure returns (BaseAppStorage storage $) {
// slither-disable-next-line assembly
assembly {
$.slot := BaseAppStorageLocation
}
}
/**
* @param endpoint The address of the LayerZero endpoint contract.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor(address endpoint) NonblockingLzAppUpgradeable(endpoint) {}
/**
* @notice BaseApp initializer
* @param initialOwner The address of the initial owner.
*/
function __BaseApp_init(address initialOwner) internal initializer {
__ReentrancyGuard_init();
__NonblockingLzApp_init(initialOwner);
__BaseApp_init_unchained();
}
function __BaseApp_init_unchained() internal initializer {
BaseAppStorage storage $ = _getBaseAppStorage();
$.defaultAdapterParams = abi.encodePacked(uint16(1), uint256(200_000)); // set LayerZero adapter params for native fees
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
BaseAppStorage storage $ = _getBaseAppStorage();
if ($.paused) revert IsPaused();
_;
}
/**
* @dev Toggles the paused state of the contract.
* @notice Only callable by the owner.
*/
function togglePause() external onlyOwner {
BaseAppStorage storage $ = _getBaseAppStorage();
bool state = $.paused;
$.paused = !state;
emit Paused(!state);
}
/**
* @notice Sets LayerZero adapter parameters.
* @param limit The limit for the adapter parameters.
* @dev Only callable by the owner. Reverts if the limit is below 200,000.
*/
function setLzAdapterParams(uint256 limit) external onlyOwner {
if (limit < 200_000) revert InvalidParam();
BaseAppStorage storage $ = _getBaseAppStorage();
$.defaultAdapterParams = abi.encodePacked(uint16(1), limit);
emit UpdateLzAdapterParams(limit);
}
/**
* @notice Bridges tokens to another chain.
* @param _dstChainId The destination chain ID.
* @param token The address of the source token.
* @param amount The amount of the token to bridge.
* @param _adapterParams Adapter parameters for the LayerZero send function.
* @dev Callable by external accounts. Reverts if the contract is paused, the token is not whitelisted, or if any parameter is invalid.
*/
function bridgeToken(uint16 _dstChainId, address token, uint256 amount, bytes memory _adapterParams)
external
payable
nonReentrant
whenNotPaused
{
if (token == address(0)) revert ZeroAddress();
if (amount == 0) revert InvalidParam();
BaseAppStorage storage $ = _getBaseAppStorage();
if (!$.whitelisted[token]) revert TokenNotAllowed();
_adapterParams = _adapterParams.length != 0 ? _adapterParams : $.defaultAdapterParams;
_send(_dstChainId, token, amount, _adapterParams);
emit BridgeToken(token, amount);
}
/**
* @notice Rescues tokens accidentally sent to the contract.
* @param token The address of the token to rescue.
* @param to The address to send the rescued tokens to.
* @param amount The amount of tokens to rescue.
* @dev Only callable by the owner.
*/
function rescueToken(address token, address to, uint256 amount) external onlyOwner {
IERC20(token).safeTransfer(to, amount);
emit TokenRescued(token, to, amount);
}
// ==================== INTERNAL ====================
/**
* @dev Updates the whitelist status of a token.
* @param token The address of the token.
* @param isWhitelisted The whitelist status of the token.
*/
function _updateWhitelistToken(address token, bool isWhitelisted) internal {
BaseAppStorage storage $ = _getBaseAppStorage();
$.whitelisted[token] = isWhitelisted;
emit Whitelisted(token, isWhitelisted);
}
/**
* @dev Handles non-blocking LayerZero receive messages.
* @param _srcChainId The source chain ID.
* @param _payload The payload containing the token, recipient, and amount.
*/
function _nonblockingLzReceive(
uint16 _srcChainId,
bytes memory, /*_srcAddress*/
uint64, /*_nonce*/
bytes memory _payload
) internal override nonReentrant whenNotPaused {
(address payloadToken, address recipient, uint256 amount) = abi.decode(_payload, (address, address, uint256));
address chainToken = _receive(payloadToken, recipient, amount);
emit TokenClaimed(_srcChainId, chainToken, recipient, amount);
}
/**
* @dev Safely transfers tokens from one address to another.
* @param token The address of the token.
* @param from The address to transfer tokens from.
* @param to The address to transfer tokens to.
* @param amount The amount of tokens to transfer.
* @return received The amount of tokens received.
*/
function _safeTransferFrom(address token, address from, address to, uint256 amount)
internal
returns (uint256 received)
{
uint256 balanceBefore = IERC20(token).balanceOf(to);
IERC20(token).safeTransferFrom(from, to, amount);
received = IERC20(token).balanceOf(to) - balanceBefore;
}
/**
* @dev Internal function to handle token sending across chains.
* @param _dstChainId The destination chain ID.
* @param _srcToken The address of the chain token to send / burn.
* @param _amount The amount of the token to send.
* @param _adapterParams Adapter parameters for the LayerZero send function.
*/
function _send(uint16 _dstChainId, address _srcToken, uint256 _amount, bytes memory _adapterParams)
internal
virtual;
/**
* @dev Internal function to handle token receiving.
* @param token The address of the mainChain token received.
* @param recipient The address of the recipient.
* @param amount The amount of the token received.
* @return The address of the token received.
*/
function _receive(address token, address recipient, uint256 amount) internal virtual returns (address);
/**
* @dev Internal function to get the main chain token address.
* @param token The address of the mainChain token.
* @return The address of the main chain token.
*/
function _getMainChainToken(address token) internal view virtual returns (address);
// ==================== VIEW ====================
function isWhitelistedToken(address token) public view returns (bool) {
BaseAppStorage storage $ = _getBaseAppStorage();
return $.whitelisted[token];
}
function getDefaultLZParam() public view returns (bytes memory) {
BaseAppStorage storage $ = _getBaseAppStorage();
return $.defaultAdapterParams;
}
/**
* @notice Estimates the fees for bridging tokens.
* @param dstChainId The destination chain ID.
* @param token The address of the source token.
* @param amount The amount of the token to bridge.
* @param _adapterParams Adapter parameters for the LayerZero send function.
* @return nativeFee The native fee for the operation.
* @return zroFee The ZRO fee for the operation.
*/
function estimateFees(uint16 dstChainId, address token, uint256 amount, bytes memory _adapterParams)
public
view
returns (uint256 nativeFee, uint256 zroFee)
{
BaseAppStorage storage $ = _getBaseAppStorage();
address mainChainToken = _getMainChainToken(token);
if (mainChainToken == address(0)) revert ZeroAddress();
bytes memory _payload = abi.encode(mainChainToken, _msgSender(), amount);
_adapterParams = _adapterParams.length != 0 ? _adapterParams : $.defaultAdapterParams;
return lzEndpoint.estimateFees(dstChainId, address(this), _payload, false, _adapterParams);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 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.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 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 Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
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.
*/
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.
*/
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 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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
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 silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.20;
import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*/
library ERC1967Utils {
// We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
// This will be fixed in Solidity 0.8.21. At that point we should remove these events.
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ExcessivelySafeCall} from "@layerzerolabs/contracts/libraries/ExcessivelySafeCall.sol";
import {LzAppUpgradeable} from "./LzAppUpgradeable.sol";
/**
* @title Nonblocking LayerZero Application
* @dev This contract extends LzAppUpgradeable and modifies its behavior to be non-blocking. Failed messages are caught
* and stored for future retries, ensuring that the message channel remains unblocked. This contract serves as an
* abstract base class and should be extended by specific implementations.
*
* Note: If the `srcAddress` is not configured properly, it will still block the message pathway from (`srcChainId`,
* `srcAddress`).
*/
abstract contract NonblockingLzAppUpgradeable is LzAppUpgradeable {
using ExcessivelySafeCall for address;
event MessageFailed(uint16 srcChainId, bytes srcAddress, uint64 nonce, bytes payload, bytes reason);
event RetryMessageSuccess(uint16 srcChainId, bytes srcAddress, uint64 nonce, bytes32 payloadHash);
/// @custom:storage-location erc7201:layerzero.storage.NonblockingLzApp
struct NonblockingLzAppStorage {
mapping(uint16 => mapping(bytes => mapping(uint64 => bytes32))) failedMessages;
}
// keccak256(abi.encode(uint256(keccak256("layerzero.storage.NonblockingLzApp")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant NonblockingLzAppStorageLocation =
0xe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600;
function _getNonblockingLzAppStorage() private pure returns (NonblockingLzAppStorage storage $) {
// slither-disable-next-line assembly
assembly {
$.slot := NonblockingLzAppStorageLocation
}
}
/**
* @param endpoint The address of the LayerZero endpoint contract.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor(address endpoint) LzAppUpgradeable(endpoint) {}
/**
* @dev Initializes the contract, setting the initial owner and endpoint addresses.
* Also chains the initialization process with the base `LzAppUpgradeable` contract.
*
* Requirements:
* - Can only be called during contract initialization.
*
* @param initialOwner The address that will initially own the contract.
*/
function __NonblockingLzApp_init(address initialOwner) internal onlyInitializing {
__NonblockingLzApp_init_unchained();
__LzApp_init(initialOwner);
}
function __NonblockingLzApp_init_unchained() internal onlyInitializing {}
/**
* @dev Retrieves the hash of the payload of a failed message for a given source chain, source address, and nonce.
*
* @param srcChainId The ID of the source chain where the message originated.
* @param srcAddress The address on the source chain where the message originated.
* @param nonce The nonce of the failed message.
* @return payloadHash The hash of the payload of the failed message.
*/
function failedMessages(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce)
external
view
returns (bytes32 payloadHash)
{
NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage();
return $.failedMessages[srcChainId][srcAddress][nonce];
}
/**
* @dev Internal function that receives LayerZero messages and attempts to process them in a non-blocking manner.
* If processing fails, the message is stored for future retries.
*
* @param srcChainId The ID of the source chain where the message originated.
* @param srcAddress The address on the source chain where the message originated.
* @param nonce The nonce of the message.
* @param payload The payload of the message.
*/
function _blockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload)
internal
virtual
override
{
(bool success, bytes memory reason) = address(this).excessivelySafeCall(
gasleft(),
150,
abi.encodeWithSelector(this.nonblockingLzReceive.selector, srcChainId, srcAddress, nonce, payload)
);
// try-catch all errors/exceptions
if (!success) {
_storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason);
}
}
/**
* @dev Internal function to store the details of a failed message for future retries.
*
* @param srcChainId The ID of the source chain where the message originated.
* @param srcAddress The address on the source chain where the message originated.
* @param nonce The nonce of the failed message.
* @param payload The payload of the failed message.
* @param reason The reason for the message's failure.
*/
function _storeFailedMessage(
uint16 srcChainId,
bytes memory srcAddress,
uint64 nonce,
bytes memory payload,
bytes memory reason
) internal virtual {
NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage();
$.failedMessages[srcChainId][srcAddress][nonce] = keccak256(payload);
emit MessageFailed(srcChainId, srcAddress, nonce, payload, reason);
}
/**
* @dev Public wrapper function for handling incoming LayerZero messages in a non-blocking manner.
* It internally calls the `_nonblockingLzReceive` function, which should be overridden in derived contracts.
*
* Requirements:
* - The caller must be the contract itself.
*
* @param srcChainId The ID of the source chain where the message originated.
* @param srcAddress The address on the source chain where the message originated.
* @param nonce The nonce of the message.
* @param payload The payload of the message.
*/
function nonblockingLzReceive(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload)
public
virtual
{
// only internal transaction
require(_msgSender() == address(this), "NonblockingLzApp: caller must be LzApp");
_nonblockingLzReceive(srcChainId, srcAddress, nonce, payload);
}
/**
* @dev Internal function that should be overridden in derived contracts to implement the logic
* for processing incoming LayerZero messages in a non-blocking manner.
*
* @param srcChainId The ID of the source chain where the message originated.
* @param srcAddress The address on the source chain where the message originated.
* @param nonce The nonce of the message.
* @param payload The payload of the message.
*/
function _nonblockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload)
internal
virtual;
/**
* @dev Allows for the manual retry of a previously failed message.
*
* Requirements:
* - There must be a stored failed message matching the provided parameters.
* - The payload hash must match the stored failed message.
*
* @param srcChainId The ID of the source chain where the failed message originated.
* @param srcAddress The address on the source chain where the failed message originated.
* @param nonce The nonce of the failed message.
* @param payload The payload of the failed message.
*/
function retryMessage(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload)
public
payable
virtual
{
NonblockingLzAppStorage storage $ = _getNonblockingLzAppStorage();
mapping(uint64 => bytes32) storage _failedMessages = $.failedMessages[srcChainId][srcAddress];
// get the payload hash value
bytes32 payloadHash = _failedMessages[nonce];
// assert there is message to retry
require(payloadHash != bytes32(0), "NonblockingLzApp: no stored message");
require(keccak256(payload) == payloadHash, "NonblockingLzApp: invalid payload");
// clear the stored message
_failedMessages[nonce] = bytes32(0);
// execute the message. revert if it fails again
_nonblockingLzReceive(srcChainId, srcAddress, nonce, payload);
emit RetryMessageSuccess(srcChainId, srcAddress, nonce, payloadHash);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @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.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
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].
*
* CAUTION: See Security Considerations above.
*/
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 v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) 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 FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.7.6;
library ExcessivelySafeCall {
uint constant LOW_28_MASK = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
/// @notice Use when you _really_ really _really_ don't trust the called
/// contract. This prevents the called contract from causing reversion of
/// the caller in as many ways as we can.
/// @dev The main difference between this and a solidity low-level call is
/// that we limit the number of bytes that the callee can cause to be
/// copied to caller memory. This prevents stupid things like malicious
/// contracts returning 10,000,000 bytes causing a local OOG when copying
/// to memory.
/// @param _target The address to call
/// @param _gas The amount of gas to forward to the remote contract
/// @param _maxCopy The maximum number of bytes of returndata to copy
/// to memory.
/// @param _calldata The data to send to the remote contract
/// @return success and returndata, as `.call()`. Returndata is capped to
/// `_maxCopy` bytes.
function excessivelySafeCall(
address _target,
uint _gas,
uint16 _maxCopy,
bytes memory _calldata
) internal returns (bool, bytes memory) {
// set up for assembly call
uint _toCopy;
bool _success;
bytes memory _returnData = new bytes(_maxCopy);
// dispatch message to recipient
// by assembly calling "handle" function
// we call via assembly to avoid memcopying a very large returndata
// returned by a malicious contract
assembly {
_success := call(
_gas, // gas
_target, // recipient
0, // ether value
add(_calldata, 0x20), // inloc
mload(_calldata), // inlen
0, // outloc
0 // outlen
)
// limit our copy to 256 bytes
_toCopy := returndatasize()
if gt(_toCopy, _maxCopy) {
_toCopy := _maxCopy
}
// Store the length of the copied bytes
mstore(_returnData, _toCopy)
// copy the bytes from returndata[0:_toCopy]
returndatacopy(add(_returnData, 0x20), 0, _toCopy)
}
return (_success, _returnData);
}
/// @notice Use when you _really_ really _really_ don't trust the called
/// contract. This prevents the called contract from causing reversion of
/// the caller in as many ways as we can.
/// @dev The main difference between this and a solidity low-level call is
/// that we limit the number of bytes that the callee can cause to be
/// copied to caller memory. This prevents stupid things like malicious
/// contracts returning 10,000,000 bytes causing a local OOG when copying
/// to memory.
/// @param _target The address to call
/// @param _gas The amount of gas to forward to the remote contract
/// @param _maxCopy The maximum number of bytes of returndata to copy
/// to memory.
/// @param _calldata The data to send to the remote contract
/// @return success and returndata, as `.call()`. Returndata is capped to
/// `_maxCopy` bytes.
function excessivelySafeStaticCall(
address _target,
uint _gas,
uint16 _maxCopy,
bytes memory _calldata
) internal view returns (bool, bytes memory) {
// set up for assembly call
uint _toCopy;
bool _success;
bytes memory _returnData = new bytes(_maxCopy);
// dispatch message to recipient
// by assembly calling "handle" function
// we call via assembly to avoid memcopying a very large returndata
// returned by a malicious contract
assembly {
_success := staticcall(
_gas, // gas
_target, // recipient
add(_calldata, 0x20), // inloc
mload(_calldata), // inlen
0, // outloc
0 // outlen
)
// limit our copy to 256 bytes
_toCopy := returndatasize()
if gt(_toCopy, _maxCopy) {
_toCopy := _maxCopy
}
// Store the length of the copied bytes
mstore(_returnData, _toCopy)
// copy the bytes from returndata[0:_toCopy]
returndatacopy(add(_returnData, 0x20), 0, _toCopy)
}
return (_success, _returnData);
}
/**
* @notice Swaps function selectors in encoded contract calls
* @dev Allows reuse of encoded calldata for functions with identical
* argument types but different names. It simply swaps out the first 4 bytes
* for the new selector. This function modifies memory in place, and should
* only be used with caution.
* @param _newSelector The new 4-byte selector
* @param _buf The encoded contract args
*/
function swapSelector(bytes4 _newSelector, bytes memory _buf) internal pure {
require(_buf.length >= 4);
uint _mask = LOW_28_MASK;
assembly {
// load the first word of
let _word := mload(add(_buf, 0x20))
// mask out the top 4 bytes
// /x
_word := and(_word, _mask)
_word := or(_newSelector, _word)
mstore(add(_buf, 0x20), _word)
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {ILayerZeroReceiver} from "@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroReceiver.sol";
import {ILayerZeroUserApplicationConfig} from
"@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroUserApplicationConfig.sol";
import {ILayerZeroEndpoint} from "@layerzerolabs/contracts/lzApp/interfaces/ILayerZeroEndpoint.sol";
import {BytesLib} from "@layerzerolabs/contracts/libraries/BytesLib.sol";
/**
* @title LzAppUpgradeable
* @dev This is a generic implementation of LzReceiver, designed for LayerZero cross-chain communication.
*
* The contract inherits from `OwnableUpgradeable` and implements `ILayerZeroReceiver` and
* `ILayerZeroUserApplicationConfig` interfaces. It provides functionality for setting and managing trusted remote
* chains and their corresponding paths, configuring minimum destination gas, payload size limitations, and more.
*
* The contract uses a custom storage location `LzAppStorage`, which includes various mappings and state variables such
* as `trustedRemoteLookup`, `minDstGasLookup`, and `payloadSizeLimitLookup`.
*
* Events:
* - `SetPrecrime(address)`: Emitted when the precrime address is set.
* - `SetTrustedRemote(uint16, bytes)`: Emitted when a trusted remote chain is set with its path.
* - `SetTrustedRemoteAddress(uint16, bytes)`: Emitted when a trusted remote chain is set with its address.
* - `SetMinDstGas(uint16, uint16, uint256)`: Emitted when minimum destination gas is set for a chain and packet type.
*
* Initialization:
* The contract should be initialized by calling `__LzApp_init` function.
*
* Permissions:
* Most administrative tasks require the sender to be the contract's owner.
*
* Note:
* The contract includes the Checks-Effects-Interactions pattern and optimizes for gas-efficiency wherever applicable.
*/
abstract contract LzAppUpgradeable is OwnableUpgradeable, ILayerZeroReceiver, ILayerZeroUserApplicationConfig {
using BytesLib for bytes;
// ua can not send payload larger than this by default, but it can be changed by the ua owner
uint256 public constant DEFAULT_PAYLOAD_SIZE_LIMIT = 10_000;
event SetPrecrime(address precrime);
event SetTrustedRemote(uint16 _remoteChainId, bytes _path);
event SetTrustedRemoteAddress(uint16 _remoteChainId, bytes _remoteAddress);
event SetMinDstGas(uint16 _dstChainId, uint16 _type, uint256 _minDstGas);
/// @custom:storage-location erc7201:layerzero.storage.LzApp
struct LzAppStorage {
mapping(uint16 => bytes) trustedRemoteLookup;
mapping(uint16 => mapping(uint16 => uint256)) minDstGasLookup;
mapping(uint16 => uint256) payloadSizeLimitLookup;
address precrime;
}
// keccak256(abi.encode(uint256(keccak256("layerzero.storage.LzApp")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant LzAppStorageLocation = 0x111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00;
function _getLzAppStorage() private pure returns (LzAppStorage storage $) {
// slither-disable-next-line assembly
assembly {
$.slot := LzAppStorageLocation
}
}
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
ILayerZeroEndpoint public immutable lzEndpoint;
/**
* @param endpoint Address of the LayerZero endpoint contract.
* @custom:oz-upgrades-unsafe-allow constructor
*/
constructor(address endpoint) {
lzEndpoint = ILayerZeroEndpoint(endpoint);
}
/**
* @dev Initializes the contract with the given `initialOwner`.
*
* Requirements:
* - The function should only be called during the initialization process.
*
* @param initialOwner Address of the initial owner of the contract.
*/
function __LzApp_init(address initialOwner) internal onlyInitializing {
__LzApp_init_unchained();
__Ownable_init(initialOwner);
}
function __LzApp_init_unchained() internal onlyInitializing {}
/**
* @dev Returns the trusted path for a given remote chain ID.
*
* @param remoteChainId The ID of the remote chain to query for a trusted path.
* @return path Bytes representation of the trusted path for the specified remote chain ID.
*/
function trustedRemoteLookup(uint16 remoteChainId) external view returns (bytes memory path) {
LzAppStorage storage $ = _getLzAppStorage();
path = $.trustedRemoteLookup[remoteChainId];
}
/**
* @dev Returns the minimum gas required for a given destination chain ID and packet type.
*
* @param dstChainId The ID of the destination chain to query for a minimum gas limit.
* @param packetType The type of packet for which the minimum gas limit is to be fetched.
* @return minGas The minimum gas limit required for the specified destination chain ID and packet type.
*/
function minDstGasLookup(uint16 dstChainId, uint16 packetType) external view returns (uint256 minGas) {
LzAppStorage storage $ = _getLzAppStorage();
minGas = $.minDstGasLookup[dstChainId][packetType];
}
/**
* @dev Returns the payload size limit for a given destination chain ID.
*
* @param dstChainId The ID of the destination chain to query for a payload size limit.
* @return size The maximum allowable payload size in bytes for the specified destination chain ID.
*/
function payloadSizeLimitLookup(uint16 dstChainId) external view returns (uint256 size) {
LzAppStorage storage $ = _getLzAppStorage();
size = $.payloadSizeLimitLookup[dstChainId];
}
/**
* @dev Returns the address of the precrime contract.
*
* @return _precrime The address of the precrime contract.
*/
function precrime() external view returns (address _precrime) {
LzAppStorage storage $ = _getLzAppStorage();
_precrime = $.precrime;
}
/**
* @dev Handles incoming LayerZero messages from a source chain.
* This function must be called by the LayerZero endpoint and validates the source of the message.
*
* Requirements:
* - Caller must be the LayerZero endpoint.
* - Source address must be a trusted remote address.
*
* @param srcChainId The ID of the source chain from which the message is sent.
* @param srcAddress The address on the source chain that is sending the message.
* @param nonce A unique identifier for the message.
* @param payload The actual data payload of the message.
*/
function lzReceive(uint16 srcChainId, bytes calldata srcAddress, uint64 nonce, bytes calldata payload)
public
virtual
override
{
LzAppStorage storage $ = _getLzAppStorage();
// lzReceive must be called by the endpoint for security
require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller");
bytes memory trustedRemote = $.trustedRemoteLookup[srcChainId];
// if will still block the message pathway from (srcChainId, srcAddress). should not receive message from
// untrusted remote.
require(
srcAddress.length == trustedRemote.length && trustedRemote.length != 0
&& keccak256(srcAddress) == keccak256(trustedRemote),
"LzApp: invalid source sending contract"
);
_blockingLzReceive(srcChainId, srcAddress, nonce, payload);
}
/**
* @dev Internal function that handles incoming LayerZero messages in a blocking manner.
* This is an abstract function and should be implemented by derived contracts.
*
* @param srcChainId The ID of the source chain from which the message is sent.
* @param srcAddress The address on the source chain that is sending the message.
* @param nonce A unique identifier for the message.
* @param payload The actual data payload of the message.
*/
function _blockingLzReceive(uint16 srcChainId, bytes memory srcAddress, uint64 nonce, bytes memory payload)
internal
virtual;
/**
* @dev Internal function to send a LayerZero message to a destination chain.
* It performs a series of validations before sending the message.
*
* Requirements:
* - Destination chain must be a trusted remote.
* - Payload size must be within the configured limit.
*
* @param dstChainId The ID of the destination chain.
* @param payload The actual data payload to be sent.
* @param refundAddress The address to which any refunds should be sent.
* @param zroPaymentAddress The address for the ZRO token payment.
* @param adapterParams Additional parameters required for the adapter.
* @param nativeFee The native fee to be sent along with the message.
*/
function _lzSend(
uint16 dstChainId,
bytes memory payload,
address payable refundAddress,
address zroPaymentAddress,
bytes memory adapterParams,
uint256 nativeFee
) internal virtual {
LzAppStorage storage $ = _getLzAppStorage();
bytes memory trustedRemote = $.trustedRemoteLookup[dstChainId];
require(trustedRemote.length != 0, "LzApp: destination chain is not a trusted source");
_checkPayloadSize(dstChainId, payload.length);
lzEndpoint.send{value: nativeFee}(
dstChainId, trustedRemote, payload, refundAddress, zroPaymentAddress, adapterParams
);
}
/**
* @dev Internal function to validate if the provided gas limit meets the minimum requirement for a given packet
* type and destination chain.
*
* Requirements:
* - The minimum destination gas limit must be set for the given packet type and destination chain.
* - Provided gas limit should be greater than or equal to the sum of the minimum gas limit and any extra gas.
*
* @param dstChainId The ID of the destination chain.
* @param packetType The type of the packet being sent.
* @param adapterParams Additional parameters required for the adapter.
* @param extraGas Extra gas to be added to the minimum required gas.
*/
function _checkGasLimit(uint16 dstChainId, uint16 packetType, bytes memory adapterParams, uint256 extraGas)
internal
view
virtual
{
LzAppStorage storage $ = _getLzAppStorage();
uint256 providedGasLimit = _getGasLimit(adapterParams);
uint256 minGasLimit = $.minDstGasLookup[dstChainId][packetType];
require(minGasLimit != 0, "LzApp: minGasLimit not set");
require(providedGasLimit >= minGasLimit + extraGas, "LzApp: gas limit is too low");
}
/**
* @dev Internal function to extract the gas limit from the adapter parameters.
*
* Requirements:
* - The `adapterParams` must be at least 34 bytes long to contain the gas limit.
*
* @param _adapterParams The adapter parameters from which the gas limit is to be extracted.
* @return gasLimit The extracted gas limit.
*/
function _getGasLimit(bytes memory _adapterParams) internal pure virtual returns (uint256 gasLimit) {
require(_adapterParams.length >= 34, "LzApp: invalid adapterParams");
// slither-disable-next-line assembly
assembly {
gasLimit := mload(add(_adapterParams, 34))
}
}
/**
* @dev Internal function to validate the size of the payload against the configured limit for a given destination
* chain.
*
* Requirements:
* - Payload size must be less than or equal to the configured size limit for the given destination chain.
*
* @param _dstChainId The ID of the destination chain.
* @param _payloadSize The size of the payload in bytes.
*/
function _checkPayloadSize(uint16 _dstChainId, uint256 _payloadSize) internal view virtual {
LzAppStorage storage $ = _getLzAppStorage();
uint256 payloadSizeLimit = $.payloadSizeLimitLookup[_dstChainId];
if (payloadSizeLimit == 0) {
// use default if not set
payloadSizeLimit = DEFAULT_PAYLOAD_SIZE_LIMIT;
}
require(_payloadSize <= payloadSizeLimit, "LzApp: payload size is too large");
}
/**
* @dev Retrieves the configuration of the LayerZero user application for a given version, chain ID, and config
* type.
*
* @param version The version for which the configuration is to be fetched.
* @param chainId The ID of the chain for which the configuration is needed.
* @param configType The type of the configuration to be retrieved.
* @return The bytes representation of the configuration.
*/
function getConfig(uint16 version, uint16 chainId, address, uint256 configType)
external
view
returns (bytes memory)
{
return lzEndpoint.getConfig(version, chainId, address(this), configType);
}
/**
* @dev Sets the configuration of the LayerZero user application for a given version, chain ID, and config type.
*
* Requirements:
* - Only the owner can set the configuration.
*
* @param version The version for which the configuration is to be set.
* @param chainId The ID of the chain for which the configuration is being set.
* @param configType The type of the configuration to be set.
* @param config The actual configuration data in bytes format.
*/
function setConfig(uint16 version, uint16 chainId, uint256 configType, bytes calldata config)
external
override
onlyOwner
{
lzEndpoint.setConfig(version, chainId, configType, config);
}
/**
* @dev Sets the version to be used for sending LayerZero messages.
*
* Requirements:
* - Only the owner can set the send version.
*
* @param version The version to be set for sending messages.
*/
function setSendVersion(uint16 version) external override onlyOwner {
lzEndpoint.setSendVersion(version);
}
/**
* @dev Sets the version to be used for receiving LayerZero messages.
*
* Requirements:
* - Only the owner can set the receive version.
*
* @param version The version to be set for receiving messages.
*/
function setReceiveVersion(uint16 version) external override onlyOwner {
lzEndpoint.setReceiveVersion(version);
}
/**
* @dev Resumes the reception of LayerZero messages from a specific source chain and address.
*
* Requirements:
* - Only the owner can force the resumption of message reception.
*
* @param srcChainId The ID of the source chain from which message reception is to be resumed.
* @param srcAddress The address on the source chain for which message reception is to be resumed.
*/
function forceResumeReceive(uint16 srcChainId, bytes calldata srcAddress) external override onlyOwner {
lzEndpoint.forceResumeReceive(srcChainId, srcAddress);
}
/**
* @dev Sets the trusted path for cross-chain communication with a specified remote chain.
*
* Requirements:
* - Only the owner can set the trusted path.
*
* @param remoteChainId The ID of the remote chain for which the trusted path is being set.
* @param path The trusted path encoded as bytes.
*/
function setTrustedRemote(uint16 remoteChainId, bytes calldata path) external onlyOwner {
LzAppStorage storage $ = _getLzAppStorage();
$.trustedRemoteLookup[remoteChainId] = path;
emit SetTrustedRemote(remoteChainId, path);
}
/**
* @dev Sets the trusted remote address for cross-chain communication with a specified remote chain.
* The function also automatically appends the contract's own address to the path.
*
* Requirements:
* - Only the owner can set the trusted remote address.
*
* @param remoteChainId The ID of the remote chain for which the trusted address is being set.
* @param remoteAddress The trusted remote address encoded as bytes.
*/
function setTrustedRemoteAddress(uint16 remoteChainId, bytes calldata remoteAddress) external onlyOwner {
LzAppStorage storage $ = _getLzAppStorage();
$.trustedRemoteLookup[remoteChainId] = abi.encodePacked(remoteAddress, address(this));
emit SetTrustedRemoteAddress(remoteChainId, remoteAddress);
}
/**
* @dev Retrieves the trusted remote address for a given remote chain.
*
* Requirements:
* - A trusted path record must exist for the specified remote chain.
*
* @param remoteChainId The ID of the remote chain for which the trusted address is needed.
* @return The trusted remote address encoded as bytes.
*/
function getTrustedRemoteAddress(uint16 remoteChainId) external view returns (bytes memory) {
LzAppStorage storage $ = _getLzAppStorage();
bytes memory path = $.trustedRemoteLookup[remoteChainId];
require(path.length != 0, "LzApp: no trusted path record");
return path.slice(0, path.length - 20); // the last 20 bytes should be address(this)
}
/**
* @dev Sets the "Precrime" address, which could be an address for handling fraudulent activities or other specific
* behaviors.
*
* Requirements:
* - Only the owner can set the Precrime address.
*
* @param _precrime The address to be set as Precrime.
*/
function setPrecrime(address _precrime) external onlyOwner {
LzAppStorage storage $ = _getLzAppStorage();
$.precrime = _precrime;
emit SetPrecrime(_precrime);
}
/**
* @dev Sets the minimum required gas for a specific packet type and destination chain.
*
* Requirements:
* - Only the owner can set the minimum destination gas.
*
* @param dstChainId The ID of the destination chain for which the minimum gas is being set.
* @param packetType The type of the packet for which the minimum gas is being set.
* @param minGas The minimum required gas in units.
*/
function setMinDstGas(uint16 dstChainId, uint16 packetType, uint256 minGas) external onlyOwner {
LzAppStorage storage $ = _getLzAppStorage();
$.minDstGasLookup[dstChainId][packetType] = minGas;
emit SetMinDstGas(dstChainId, packetType, minGas);
}
/**
* @dev Sets the payload size limit for a specific destination chain.
*
* Requirements:
* - Only the owner can set the payload size limit.
*
* @param dstChainId The ID of the destination chain for which the payload size limit is being set.
* @param size The size limit in bytes.
*/
function setPayloadSizeLimit(uint16 dstChainId, uint256 size) external onlyOwner {
LzAppStorage storage $ = _getLzAppStorage();
$.payloadSizeLimitLookup[dstChainId] = size;
}
/**
* @dev Checks whether a given source chain and address are trusted for receiving LayerZero messages.
*
* @param srcChainId The ID of the source chain to be checked.
* @param srcAddress The address on the source chain to be verified.
* @return A boolean indicating whether the source chain and address are trusted.
*/
function isTrustedRemote(uint16 srcChainId, bytes calldata srcAddress) external view returns (bool) {
LzAppStorage storage $ = _getLzAppStorage();
bytes memory trustedSource = $.trustedRemoteLookup[srcChainId];
return keccak256(trustedSource) == keccak256(srcAddress);
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroReceiver {
// @notice LayerZero endpoint will invoke this function to deliver the message on the destination
// @param _srcChainId - the source endpoint identifier
// @param _srcAddress - the source sending contract address from the source chain
// @param _nonce - the ordered message nonce
// @param _payload - the signed payload is the UA bytes has encoded to be sent
function lzReceive(
uint16 _srcChainId,
bytes calldata _srcAddress,
uint64 _nonce,
bytes calldata _payload
) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(
uint16 _version,
uint16 _chainId,
uint _configType,
bytes calldata _config
) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
import "./ILayerZeroUserApplicationConfig.sol";
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(
uint16 _dstChainId,
bytes calldata _destination,
bytes calldata _payload,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(
uint16 _srcChainId,
bytes calldata _srcAddress,
address _dstAddress,
uint64 _nonce,
uint _gasLimit,
bytes calldata _payload
) external;
// @notice get the inboundNonce of a lzApp from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(
uint16 _srcChainId,
bytes calldata _srcAddress,
bytes calldata _payload
) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(
uint16 _version,
uint16 _chainId,
address _userApplication,
uint _configType
) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}// SPDX-License-Identifier: Unlicense /* * @title Solidity Bytes Arrays Utils * @author Gonçalo Sá <[email protected]> * * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity. * The library lets you concatenate, slice and type cast bytes arrays both in memory and storage. */ pragma solidity >=0.8.0 <0.9.0; library BytesLib { function concat(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bytes memory) { bytes memory tempBytes; assembly { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // Store the length of the first bytes array at the beginning of // the memory for tempBytes. let length := mload(_preBytes) mstore(tempBytes, length) // Maintain a memory counter for the current write location in the // temp bytes array by adding the 32 bytes for the array length to // the starting location. let mc := add(tempBytes, 0x20) // Stop copying when the memory counter reaches the length of the // first bytes array. let end := add(mc, length) for { // Initialize a copy counter to the start of the _preBytes data, // 32 bytes into its memory. let cc := add(_preBytes, 0x20) } lt(mc, end) { // Increase both counters by 32 bytes each iteration. mc := add(mc, 0x20) cc := add(cc, 0x20) } { // Write the _preBytes data into the tempBytes memory 32 bytes // at a time. mstore(mc, mload(cc)) } // Add the length of _postBytes to the current length of tempBytes // and store it as the new length in the first 32 bytes of the // tempBytes memory. length := mload(_postBytes) mstore(tempBytes, add(length, mload(tempBytes))) // Move the memory counter back from a multiple of 0x20 to the // actual end of the _preBytes data. mc := end // Stop copying when the memory counter reaches the new combined // length of the arrays. end := add(mc, length) for { let cc := add(_postBytes, 0x20) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } // Update the free-memory pointer by padding our last write location // to 32 bytes: add 31 bytes to the end of tempBytes to move to the // next 32 byte block, then round down to the nearest multiple of // 32. If the sum of the length of the two arrays is zero then add // one before rounding down to leave a blank 32 bytes (the length block with 0). mstore( 0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ) ) } return tempBytes; } function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal { assembly { // Read the first 32 bytes of _preBytes storage, which is the length // of the array. (We don't need to use the offset into the slot // because arrays use the entire slot.) let fslot := sload(_preBytes.slot) // Arrays of 31 bytes or less have an even value in their slot, // while longer arrays have an odd value. The actual length is // the slot divided by two for odd values, and the lowest order // byte divided by two for even values. // If the slot is even, bitwise and the slot with 255 and divide by // two to get the length. If the slot is odd, bitwise and the slot // with -1 and divide by two. let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) let newlength := add(slength, mlength) // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage switch add(lt(slength, 32), lt(newlength, 32)) case 2 { // Since the new array still fits in the slot, we just need to // update the contents of the slot. // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length sstore( _preBytes.slot, // all the modifications to the slot are inside this // next block add( // we can just add to the slot contents because the // bytes we want to change are the LSBs fslot, add( mul( div( // load the bytes from memory mload(add(_postBytes, 0x20)), // zero all bytes to the right exp(0x100, sub(32, mlength)) ), // and now shift left the number of bytes to // leave space for the length in the slot exp(0x100, sub(32, newlength)) ), // increase length by the double of the memory // bytes length mul(mlength, 2) ) ) ) } case 1 { // The stored value fits in the slot, but the combined value // will exceed it. // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // The contents of the _postBytes array start 32 bytes into // the structure. Our first read should obtain the `submod` // bytes that can fit into the unused space in the last word // of the stored array. To get this, we read 32 bytes starting // from `submod`, so the data we read overlaps with the array // contents by `submod` bytes. Masking the lowest-order // `submod` bytes allows us to add that value directly to the // stored value. let submod := sub(32, slength) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(and(fslot, 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00), and(mload(mc), mask))) for { mc := add(mc, 0x20) sc := add(sc, 1) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } default { // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) // Start copying to the last used word of the stored array. let sc := add(keccak256(0x0, 0x20), div(slength, 32)) // save new length sstore(_preBytes.slot, add(mul(newlength, 2), 1)) // Copy over the first `submod` bytes of the new data as in // case 1 above. let slengthmod := mod(slength, 32) let mlengthmod := mod(mlength, 32) let submod := sub(32, slengthmod) let mc := add(_postBytes, submod) let end := add(_postBytes, mlength) let mask := sub(exp(0x100, submod), 1) sstore(sc, add(sload(sc), and(mload(mc), mask))) for { sc := add(sc, 1) mc := add(mc, 0x20) } lt(mc, end) { sc := add(sc, 1) mc := add(mc, 0x20) } { sstore(sc, mload(mc)) } mask := exp(0x100, sub(mc, end)) sstore(sc, mul(div(mload(mc), mask), mask)) } } } function slice( bytes memory _bytes, uint _start, uint _length ) internal pure returns (bytes memory) { require(_length + 31 >= _length, "slice_overflow"); require(_bytes.length >= _start + _length, "slice_outOfBounds"); bytes memory tempBytes; assembly { switch iszero(_length) case 0 { // Get a location of some free memory and store it in tempBytes as // Solidity does for memory variables. tempBytes := mload(0x40) // The first word of the slice result is potentially a partial // word read from the original array. To read it, we calculate // the length of that partial word and start copying that many // bytes into the array. The first word we copy will start with // data we don't care about, but the last `lengthmod` bytes will // land at the beginning of the contents of the new array. When // we're done copying, we overwrite the full first word with // the actual length of the slice. let lengthmod := and(_length, 31) // The multiplication in the next line is necessary // because when slicing multiples of 32 bytes (lengthmod == 0) // the following copy loop was copying the origin's length // and then ending prematurely not copying everything it should. let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod))) let end := add(mc, _length) for { // The multiplication in the next line has the same exact purpose // as the one above. let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start) } lt(mc, end) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { mstore(mc, mload(cc)) } mstore(tempBytes, _length) //update free-memory pointer //allocating the array padded to 32 bytes like the compiler does now mstore(0x40, and(add(mc, 31), not(31))) } //if we want a zero-length slice let's just return a zero-length array default { tempBytes := mload(0x40) //zero out the 32 bytes slice we are about to return //we need to do it because Solidity does not garbage collect mstore(tempBytes, 0) mstore(0x40, add(tempBytes, 0x20)) } } return tempBytes; } function toAddress(bytes memory _bytes, uint _start) internal pure returns (address) { require(_bytes.length >= _start + 20, "toAddress_outOfBounds"); address tempAddress; assembly { tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000) } return tempAddress; } function toUint8(bytes memory _bytes, uint _start) internal pure returns (uint8) { require(_bytes.length >= _start + 1, "toUint8_outOfBounds"); uint8 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x1), _start)) } return tempUint; } function toUint16(bytes memory _bytes, uint _start) internal pure returns (uint16) { require(_bytes.length >= _start + 2, "toUint16_outOfBounds"); uint16 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x2), _start)) } return tempUint; } function toUint32(bytes memory _bytes, uint _start) internal pure returns (uint32) { require(_bytes.length >= _start + 4, "toUint32_outOfBounds"); uint32 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x4), _start)) } return tempUint; } function toUint64(bytes memory _bytes, uint _start) internal pure returns (uint64) { require(_bytes.length >= _start + 8, "toUint64_outOfBounds"); uint64 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x8), _start)) } return tempUint; } function toUint96(bytes memory _bytes, uint _start) internal pure returns (uint96) { require(_bytes.length >= _start + 12, "toUint96_outOfBounds"); uint96 tempUint; assembly { tempUint := mload(add(add(_bytes, 0xc), _start)) } return tempUint; } function toUint128(bytes memory _bytes, uint _start) internal pure returns (uint128) { require(_bytes.length >= _start + 16, "toUint128_outOfBounds"); uint128 tempUint; assembly { tempUint := mload(add(add(_bytes, 0x10), _start)) } return tempUint; } function toUint256(bytes memory _bytes, uint _start) internal pure returns (uint) { require(_bytes.length >= _start + 32, "toUint256_outOfBounds"); uint tempUint; assembly { tempUint := mload(add(add(_bytes, 0x20), _start)) } return tempUint; } function toBytes32(bytes memory _bytes, uint _start) internal pure returns (bytes32) { require(_bytes.length >= _start + 32, "toBytes32_outOfBounds"); bytes32 tempBytes32; assembly { tempBytes32 := mload(add(add(_bytes, 0x20), _start)) } return tempBytes32; } function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) { bool success = true; assembly { let length := mload(_preBytes) // if lengths don't match the arrays are not equal switch eq(length, mload(_postBytes)) case 1 { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 let mc := add(_preBytes, 0x20) let end := add(mc, length) for { let cc := add(_postBytes, 0x20) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) } eq(add(lt(mc, end), cb), 2) { mc := add(mc, 0x20) cc := add(cc, 0x20) } { // if any of these checks fails then arrays are not equal if iszero(eq(mload(mc), mload(cc))) { // unsuccess: success := 0 cb := 0 } } } default { // unsuccess: success := 0 } } return success; } function equalStorage(bytes storage _preBytes, bytes memory _postBytes) internal view returns (bool) { bool success = true; assembly { // we know _preBytes_offset is 0 let fslot := sload(_preBytes.slot) // Decode the length of the stored array like in concatStorage(). let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2) let mlength := mload(_postBytes) // if lengths don't match the arrays are not equal switch eq(slength, mlength) case 1 { // slength can contain both the length and contents of the array // if length < 32 bytes so let's prepare for that // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage if iszero(iszero(slength)) { switch lt(slength, 32) case 1 { // blank the last byte which is the length fslot := mul(div(fslot, 0x100), 0x100) if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) { // unsuccess: success := 0 } } default { // cb is a circuit breaker in the for loop since there's // no said feature for inline assembly loops // cb = 1 - don't breaker // cb = 0 - break let cb := 1 // get the keccak hash to get the contents of the array mstore(0x0, _preBytes.slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength) // the next line is the loop condition: // while(uint256(mc < end) + cb == 2) for { } eq(add(lt(mc, end), cb), 2) { sc := add(sc, 1) mc := add(mc, 0x20) } { if iszero(eq(sload(sc), mload(mc))) { // unsuccess: success := 0 cb := 0 } } } } } default { // unsuccess: success := 0 } } return success; } }
{
"remappings": [
"src/=src/",
"forge-std/=lib/forge-std/src/",
"@tangible/=lib/tangible-foundation-contracts/src/",
"@layerzerolabs/contracts-upgradeable/=lib/tangible-foundation-contracts/src/layerzero/",
"@layerzerolabs/contracts/=lib/tangible-foundation-contracts/lib/layerzerolabs/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/tangible-foundation-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"layerzerolabs/=lib/tangible-foundation-contracts/lib/layerzerolabs/contracts/",
"openzeppelin-contracts-upgradeable/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/tangible-foundation-contracts/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/",
"tangible-foundation-contracts/=lib/tangible-foundation-contracts/src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"endpoint_","type":"address"},{"internalType":"uint16","name":"dstChainId_","type":"uint16"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidParam","type":"error"},{"inputs":[],"name":"IsPaused","type":"error"},{"inputs":[],"name":"NotAuthorized","type":"error"},{"inputs":[],"name":"NotInitializing","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":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TokenNotAllowed","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BridgeToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes","name":"payload","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"MessageFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":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":"bool","name":"isPaused","type":"bool"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"srcChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"srcAddress","type":"bytes"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"name":"RetryMessageSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"_type","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"_minDstGas","type":"uint256"}],"name":"SetMinDstGas","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"precrime","type":"address"}],"name":"SetPrecrime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_path","type":"bytes"}],"name":"SetTrustedRemote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"_remoteChainId","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"_remoteAddress","type":"bytes"}],"name":"SetTrustedRemoteAddress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint16","name":"srcId","type":"uint16"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokenRescued","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"limit","type":"uint256"}],"name":"UpdateLzAdapterParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"srcToken","type":"address"},{"indexed":true,"internalType":"address","name":"dstToken","type":"address"}],"name":"UpdateTokenPairs","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bool","name":"isWhitelisted","type":"bool"}],"name":"Whitelisted","type":"event"},{"inputs":[],"name":"DEFAULT_PAYLOAD_SIZE_LIMIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"bridgeToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateFees","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"failedMessages","outputs":[{"internalType":"bytes32","name":"payloadHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"}],"name":"forceResumeReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"configType","type":"uint256"}],"name":"getConfig","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDefaultLZParam","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"}],"name":"getTrustedRemoteAddress","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"}],"name":"isTrustedRemote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isWhitelistedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lzEndpoint","outputs":[{"internalType":"contract ILayerZeroEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"lzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint16","name":"packetType","type":"uint16"}],"name":"minDstGasLookup","outputs":[{"internalType":"uint256","name":"minGas","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"nonblockingLzReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"}],"name":"payloadSizeLimitLookup","outputs":[{"internalType":"uint256","name":"size","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"precrime","outputs":[{"internalType":"address","name":"_precrime","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"srcToken","type":"address"}],"name":"removeWhitelistToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"retryMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"},{"internalType":"uint16","name":"chainId","type":"uint16"},{"internalType":"uint256","name":"configType","type":"uint256"},{"internalType":"bytes","name":"config","type":"bytes"}],"name":"setConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"setLzAdapterParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint16","name":"packetType","type":"uint16"},{"internalType":"uint256","name":"minGas","type":"uint256"}],"name":"setMinDstGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"dstChainId","type":"uint16"},{"internalType":"uint256","name":"size","type":"uint256"}],"name":"setPayloadSizeLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_precrime","type":"address"}],"name":"setPrecrime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"setReceiveVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"version","type":"uint16"}],"name":"setSendVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"},{"internalType":"bytes","name":"path","type":"bytes"}],"name":"setTrustedRemote","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"},{"internalType":"bytes","name":"remoteAddress","type":"bytes"}],"name":"setTrustedRemoteAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"srcToken","type":"address"},{"internalType":"address","name":"dstToken","type":"address"}],"name":"setWhitelistToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"remoteChainId","type":"uint16"}],"name":"trustedRemoteLookup","outputs":[{"internalType":"bytes","name":"path","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]Contract Creation Code
60e06040523060805234801562000014575f80fd5b5060405162003c7638038062003c76833981016040819052620000379162000052565b6001600160a01b0390911660a05261ffff1660c0526200009e565b5f806040838503121562000064575f80fd5b82516001600160a01b03811681146200007b575f80fd5b602084015190925061ffff8116811462000093575f80fd5b809150509250929050565b60805160a05160c051613b676200010f5f395f6122aa01525f81816105d501528181610799015281816109e301528181610aa501528181610c2901528181610dac0152818161170f01528181611da101526129cd01525f8181611efb01528181611f2401526120680152613b675ff3fe60806040526004361061021c575f3560e01c80639f38369a1161011e578063cbed8b9c116100a8578063e5711e8b1161006d578063e5711e8b146106ed578063e9ee91071461070c578063eb8d72b71461072b578063f2fde38b1461074a578063f5ecbdbc14610769575f80fd5b8063cbed8b9c1461065e578063d1deba1f1461067d578063d583c12c14610690578063d60726e5146106af578063df2a5b3b146106ce575f80fd5b8063b353aaa7116100ee578063b353aaa7146105c4578063baf3292d146105f7578063c446183414610616578063c4ae31681461062b578063c4d66de81461063f575f80fd5b80639f38369a14610537578063a6c3d16514610556578063ab37f48614610575578063ad3cb1cc14610594575f80fd5b806352d1902d116101aa5780638cfd8f5c1161016f5780638cfd8f5c146104265780638da5cb5b146104845780638e4c3fe7146104d4578063950c8a74146104e8578063987fdcbe14610524575f80fd5b806352d1902d146103945780635b8c41e6146103a857806366ad5c8a146103c7578063715018a6146103e65780637533d788146103fa575f80fd5b806312e7d907116101f057806312e7d9071461029e5780633d8b38f6146102d75780633f1f4fa41461030657806342d65a8d146103625780634f1ef28614610381575f80fd5b80621d35671461022057806307e0db17146102415780630df374831461026057806310ddb1371461027f575b5f80fd5b34801561022b575f80fd5b5061023f61023a366004612fd7565b610788565b005b34801561024c575f80fd5b5061023f61025b366004613064565b6109c2565b34801561026b575f80fd5b5061023f61027a36600461307d565b610a46565b34801561028a575f80fd5b5061023f610299366004613064565b610a84565b3480156102a9575f80fd5b506102bd6102b8366004613175565b610adc565b604080519283526020830191909152015b60405180910390f35b3480156102e2575f80fd5b506102f66102f13660046131da565b610cb4565b60405190151581526020016102ce565b348015610311575f80fd5b50610354610320366004613064565b61ffff165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604090205490565b6040519081526020016102ce565b34801561036d575f80fd5b5061023f61037c3660046131da565b610d8d565b61023f61038f366004613228565b610e17565b34801561039f575f80fd5b50610354610e36565b3480156103b3575f80fd5b506103546103c2366004613274565b610e51565b3480156103d2575f80fd5b5061023f6103e1366004612fd7565b610ec5565b3480156103f1575f80fd5b5061023f610f9f565b348015610405575f80fd5b50610419610414366004613064565b610fb2565b6040516102ce9190613321565b348015610431575f80fd5b50610354610440366004613333565b61ffff9182165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b016020908152604080832093909416825291909152205490565b34801561048f575f80fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03165b6040516001600160a01b0390911681526020016102ce565b3480156104df575f80fd5b50610419611067565b3480156104f3575f80fd5b507f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b03546001600160a01b03166104bc565b61023f610532366004613175565b611127565b348015610542575f80fd5b50610419610551366004613064565b611316565b348015610561575f80fd5b5061023f6105703660046131da565b611436565b348015610580575f80fd5b506102f661058f366004613364565b6114ce565b34801561059f575f80fd5b50610419604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156105cf575f80fd5b506104bc7f000000000000000000000000000000000000000000000000000000000000000081565b348015610602575f80fd5b5061023f610611366004613364565b61150a565b348015610621575f80fd5b5061035461271081565b348015610636575f80fd5b5061023f611596565b34801561064a575f80fd5b5061023f610659366004613364565b6115ef565b348015610669575f80fd5b5061023f61067836600461337f565b6116f0565b61023f61068b366004612fd7565b611780565b34801561069b575f80fd5b5061023f6106aa3660046133e8565b61198d565b3480156106ba575f80fd5b5061023f6106c93660046133ff565b611a4d565b3480156106d9575f80fd5b5061023f6106e8366004613436565b611b15565b3480156106f8575f80fd5b5061023f61070736600461346f565b611bac565b348015610717575f80fd5b5061023f610726366004613364565b611c1a565b348015610736575f80fd5b5061023f6107453660046131da565b611ccb565b348015610755575f80fd5b5061023f610764366004613364565b611d33565b348015610774575f80fd5b506104196107833660046134ad565b611d70565b5f80516020613b12833981519152337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316146108135760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff87165f9081526020829052604081208054610830906134f7565b80601f016020809104026020016040519081016040528092919081815260200182805461085c906134f7565b80156108a75780601f1061087e576101008083540402835291602001916108a7565b820191905f5260205f20905b81548152906001019060200180831161088a57829003601f168201915b505050505090508051878790501480156108c15750805115155b80156108e95750805160208201206040516108df908990899061352f565b6040518091039020145b6109445760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b606482015260840161080a565b6109b88888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525050604080516020601f8b018190048102820181019092528981528b9350915089908990819084018382808284375f92019190915250611e1d92505050565b5050505050505050565b6109ca611e95565b6040516307e0db1760e01b815261ffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307e0db17906024015b5f604051808303815f87803b158015610a2d575f80fd5b505af1158015610a3f573d5f803e3d5ffd5b5050505050565b610a4e611e95565b61ffff919091165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b026020526040902055565b610a8c611e95565b6040516310ddb13760e01b815261ffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906310ddb13790602401610a16565b5f805f80516020613ad283398151915281610b1a876001600160a01b039081165f9081525f80516020613a7283398151915260205260409020541690565b90506001600160a01b038116610b435760405163d92e233d60e01b815260040160405180910390fd5b604080516001600160a01b03831660208201523381830152606080820189905282518083039091018152608090910190915285515f03610c0d57826001018054610b8c906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb8906134f7565b8015610c035780601f10610bda57610100808354040283529160200191610c03565b820191905f5260205f20905b815481529060010190602001808311610be657829003601f168201915b5050505050610c0f565b855b60405163040a7bb160e41b81529096506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906340a7bb1090610c66908c90309086905f908d9060040161353e565b6040805180830381865afa158015610c80573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ca49190613591565b9450945050505094509492505050565b61ffff83165f9081525f80516020613b128339815191526020819052604082208054839190610ce2906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0e906134f7565b8015610d595780601f10610d3057610100808354040283529160200191610d59565b820191905f5260205f20905b815481529060010190602001808311610d3c57829003601f168201915b505050505090508484604051610d7092919061352f565b6040518091039020818051906020012014925050505b9392505050565b610d95611e95565b6040516342d65a8d60e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342d65a8d90610de5908690869086906004016135db565b5f604051808303815f87803b158015610dfc575f80fd5b505af1158015610e0e573d5f803e3d5ffd5b50505050505050565b610e1f611ef0565b610e2882611f94565b610e328282611f9c565b5050565b5f610e3f61205d565b505f80516020613a9283398151915290565b61ffff84165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602081905260408083209051610e94908790879061352f565b908152604080519182900360209081019092206001600160401b0386165f9081529252902054915050949350505050565b333014610f235760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b606482015260840161080a565b610f978686868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525050604080516020601f8901819004810282018101909252878152899350915087908790819084018382808284375f920191909152506120a692505050565b505050505050565b610fa7611e95565b610fb05f612177565b565b61ffff81165f9081525f80516020613b128339815191526020819052604090912080546060929190610fe3906134f7565b80601f016020809104026020016040519081016040528092919081815260200182805461100f906134f7565b801561105a5780601f106110315761010080835404028352916020019161105a565b820191905f5260205f20905b81548152906001019060200180831161103d57829003601f168201915b5050505050915050919050565b7f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600180546060915f80516020613ad2833981519152916110a5906134f7565b80601f01602080910402602001604051908101604052809291908181526020018280546110d1906134f7565b801561111c5780601f106110f35761010080835404028352916020019161111c565b820191905f5260205f20905b8154815290600101906020018083116110ff57829003601f168201915b505050505091505090565b61112f6121e7565b5f80516020613ad2833981519152805460ff161561116057604051631309a56360e01b815260040160405180910390fd5b6001600160a01b0384166111875760405163d92e233d60e01b815260040160405180910390fd5b825f036111a757604051633494a40d60e21b815260040160405180910390fd5b6001600160a01b0384165f9081527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600260205260409020545f80516020613ad28339815191529060ff1661120d5760405163514e24c360e11b815260040160405180910390fd5b82515f036112a557806001018054611224906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054611250906134f7565b801561129b5780601f106112725761010080835404028352916020019161129b565b820191905f5260205f20905b81548152906001019060200180831161127e57829003601f168201915b50505050506112a7565b825b92506112b58686868661221e565b846001600160a01b03167faace68a8a572e895e6d32578e0225016942d4c7734b4574a5e26fffce5eb7754856040516112f091815260200190565b60405180910390a2505061131060015f80516020613ab283398151915255565b50505050565b61ffff81165f9081525f80516020613b1283398151915260208190526040822080546060939190611346906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054611372906134f7565b80156113bd5780601f10611394576101008083540402835291602001916113bd565b820191905f5260205f20905b8154815290600101906020018083116113a057829003601f168201915b5050505050905080515f036114145760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f7264000000604482015260640161080a565b61142e5f60148351611426919061360c565b8391906122e7565b949350505050565b61143e611e95565b6040515f80516020613b12833981519152906114629084908490309060200161361f565b60408051601f1981840301815291815261ffff86165f9081526020849052209061148c908261368a565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8484846040516114c0939291906135db565b60405180910390a150505050565b6001600160a01b03165f9081527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac216002602052604090205460ff1690565b611512611e95565b7f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0380546001600160a01b0319166001600160a01b0383169081179091556040519081525f80516020613b12833981519152907f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b906020015b60405180910390a15050565b61159e611e95565b5f80516020613ad2833981519152805460ff8116801560ff1990921682178355604051918252907f0e2fb031ee032dc02d8011dc50b816eb450cf856abd8261680dac74f72165bd29060200161158a565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f811580156116205750825b90505f826001600160401b0316600114801561163b5750303b155b905081158015611649575080155b156116675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561169157845460ff60401b1916600160401b1785555b6116996123f3565b6116a2866123fb565b8315610f9757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2906020015b60405180910390a1505050505050565b6116f8611e95565b6040516332fb62e760e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063cbed8b9c9061174c9088908890889088908890600401613745565b5f604051808303815f87803b158015611763575f80fd5b505af1158015611775573d5f803e3d5ffd5b505050505050505050565b61ffff86165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d86006020819052604080832090519192916117c6908990899061352f565b90815260408051602092819003830190206001600160401b0388165f90815292819052912054909150806118485760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b606482015260840161080a565b80858560405161185992919061352f565b6040518091039020146118b85760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b606482015260840161080a565b6001600160401b0386165f90815260208381526040808320929092558151601f8a01829004820281018201909252888252611943918b918b908b90819084018382808284375f9201919091525050604080516020601f8c018190048102820181019092528a81528c935091508a908a90819084018382808284375f920191909152506120a692505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e5898989898560405161197a95949392919061377d565b60405180910390a1505050505050505050565b611995611e95565b62030d408110156119b957604051633494a40d60e21b815260040160405180910390fd5b60408051600160f01b602082015260228082018490528251808303909101815260429091019091525f80516020613ad2833981519152907f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600190611a1c908261368a565b506040518281527f662c05f57b360ad4fcbac92752d55be66104d4a8a0602bdbac3183da2019f6409060200161158a565b611a55611e95565b6001600160a01b0382161580611a7257506001600160a01b038116155b15611a905760405163d92e233d60e01b815260040160405180910390fd5b611a9b8260016124b6565b6001600160a01b038281165f8181525f80516020613a728339815191526020819052604080832080546001600160a01b031990811696881696871790915585845281842080549091168517905551909392917fabd9ef659885734886a5f10f58870113f8b657716ae8cd4a5eed6babba9d7b0791a3505050565b611b1d611e95565b61ffff8381165f8181527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602090815260408083209487168084529482529182902085905581519283528201929092529081018290525f80516020613b12833981519152907f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016114c0565b611bb4611e95565b611bc86001600160a01b0384168383612544565b816001600160a01b0316836001600160a01b03167f4143f7b5cb6ea007914c32b8a3e64cebc051d7f493fa0755454da1e47701e12583604051611c0d91815260200190565b60405180910390a3505050565b611c22611e95565b6001600160a01b038116611c495760405163d92e233d60e01b815260040160405180910390fd5b611c53815f6124b6565b6001600160a01b038181165f8181525f80516020613a728339815191526020819052604080832080546001600160a01b0319808216909255909516808452818420805490961690955551909392907fabd9ef659885734886a5f10f58870113f8b657716ae8cd4a5eed6babba9d7b07908390a3505050565b611cd3611e95565b61ffff83165f9081525f80516020613b1283398151915260208190526040909120611cff8385836137b7565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8484846040516114c0939291906135db565b611d3b611e95565b6001600160a01b038116611d6457604051631e4fbdf760e01b81525f600482015260240161080a565b611d6d81612177565b50565b604051633d7b2f6f60e21b815261ffff808616600483015284166024820152306044820152606481018290526060907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f5ecbdbc906084015f60405180830381865afa158015611ded573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611e149190810190613871565b95945050505050565b5f80611e7f5a60966366ad5c8a60e01b89898989604051602401611e4494939291906138d9565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152309291906125a3565b9150915081610f9757610f978686868685612627565b33611ec77f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614610fb05760405163118cdaa760e01b815233600482015260240161080a565b306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161480611f7657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611f6a5f80516020613a92833981519152546001600160a01b031690565b6001600160a01b031614155b15610fb05760405163703e46dd60e11b815260040160405180910390fd5b611d6d611e95565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611ff6575060408051601f3d908101601f19168201909252611ff391810190613916565b60015b61201e57604051634c9c8ce360e01b81526001600160a01b038316600482015260240161080a565b5f80516020613a92833981519152811461204e57604051632a87526960e21b81526004810182905260240161080a565b61205883836126cf565b505050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610fb05760405163703e46dd60e11b815260040160405180910390fd5b6120ae6121e7565b5f80516020613ad2833981519152805460ff16156120df57604051631309a56360e01b815260040160405180910390fd5b5f805f848060200190518101906120f6919061392d565b9250925092505f612108848484612724565b9050826001600160a01b0316816001600160a01b03168a61ffff167f2d5ac612d9c6868638a5cda69e2027394838483929e459f2e99ad9c413bf3ad78560405161215491815260200190565b60405180910390a4505050505061131060015f80516020613ab283398151915255565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f80516020613ab283398151915280546001190161221857604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b61222a83333085612795565b9150815f0361224c5760405163162908e360e11b815260040160405180910390fd5b6001600160a01b038381165f9081525f80516020613a728339815191526020818152604092839020548351941690840181905233848401819052606080860188905284518087039091018152608090950190935290929091610e0e907f00000000000000000000000000000000000000000000000000000000000000009083905f8834612897565b60015f80516020613ab283398151915255565b6060816122f581601f61396d565b10156123345760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b604482015260640161080a565b61233e828461396d565b845110156123825760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b604482015260640161080a565b6060821580156123a05760405191505f8252602082016040526123ea565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156123d95780518352602092830192016123c1565b5050858452601f01601f1916604052505b50949350505050565b610fb0612a46565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f8115801561242c5750825b90505f826001600160401b031660011480156124475750303b155b905081158015612455575080155b156124735760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561249d57845460ff60401b1916600160401b1785555b6124a5612a7c565b6124ae86612a8c565b6116a2612aa5565b6001600160a01b0382165f8181527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac2160026020908152604091829020805460ff191685151590811790915591519182525f80516020613ad283398151915292917fa54714518c5d275fdcd3d2a461e4858e4e8cb04fb93cd0bca9d6d34115f26440910160405180910390a2505050565b6040516001600160a01b0383811660248301526044820183905261205891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612bdf565b5f60605f805f8661ffff166001600160401b038111156125c5576125c56130b9565b6040519080825280601f01601f1916602001820160405280156125ef576020820181803683370190505b5090505f808751602089015f8d8df191503d92508683111561260f578692505b828152825f602083013e909890975095505050505050565b815160208084019190912061ffff87165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600928390526040908190209051612673908890613980565b9081526040805191829003602090810183206001600160401b0389165f908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c906116e0908890889088908890889061399b565b6126d882612c40565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561271c576120588282612ca3565b610e32612d17565b6001600160a01b038381165f9081525f80516020613a728339815191526020819052604082205491929091168015806127635750612761816114ce565b155b156127815760405163514e24c360e11b815260040160405180910390fd5b611e146001600160a01b0382168686612544565b6040516370a0823160e01b81526001600160a01b0383811660048301525f9182918716906370a0823190602401602060405180830381865afa1580156127dd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128019190613916565b90506128186001600160a01b038716868686612d36565b6040516370a0823160e01b81526001600160a01b0385811660048301528291908816906370a0823190602401602060405180830381865afa15801561285f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128839190613916565b61288d919061360c565b9695505050505050565b61ffff86165f9081525f80516020613b1283398151915260208190526040822080549192916128c5906134f7565b80601f01602080910402602001604051908101604052809291908181526020018280546128f1906134f7565b801561293c5780601f106129135761010080835404028352916020019161293c565b820191905f5260205f20905b81548152906001019060200180831161291f57829003601f168201915b5050505050905080515f036129ac5760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b606482015260840161080a565b6129b7888851612d6f565b60405162c5803160e81b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c5803100908590612a0e908c9086908d908d908d908d906004016139ec565b5f604051808303818588803b158015612a25575f80fd5b505af1158015612a37573d5f803e3d5ffd5b50505050505050505050505050565b5f80516020613af283398151915254600160401b900460ff16610fb057604051631afcd79f60e31b815260040160405180910390fd5b612a84612a46565b610fb0612e0c565b612a94612a46565b612a9c6123f3565b611d6d81612e14565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f81158015612ad65750825b90505f826001600160401b03166001148015612af15750303b155b905081158015612aff575080155b15612b1d5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315612b4757845460ff60401b1916600160401b1785555b5f5f80516020613ad2833981519152604051600160f01b602082015262030d406022820152909150604201604051602081830303815290604052816001019081612b91919061368a565b50508315610a3f57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050565b5f612bf36001600160a01b03841683612e2d565b905080515f14158015612c17575080806020019051810190612c159190613a52565b155b1561205857604051635274afe760e01b81526001600160a01b038416600482015260240161080a565b806001600160a01b03163b5f03612c7557604051634c9c8ce360e01b81526001600160a01b038216600482015260240161080a565b5f80516020613a9283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b031684604051612cbf9190613980565b5f60405180830381855af49150503d805f8114612cf7576040519150601f19603f3d011682016040523d82523d5f602084013e612cfc565b606091505b5091509150612d0c858383612e3a565b925050505b92915050565b3415610fb05760405163b398979f60e01b815260040160405180910390fd5b6040516001600160a01b0384811660248301528381166044830152606482018390526113109186918216906323b872dd90608401612571565b61ffff82165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0260205260408120545f80516020613b1283398151915291819003612dbc57506127105b808311156113105760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c61726765604482015260640161080a565b6122d4612a46565b612e1c612a46565b612e246123f3565b611d6d81612e96565b6060610d8683835f612ea7565b606082612e4f57612e4a82612f36565b610d86565b8151158015612e6657506001600160a01b0384163b155b15612e8f57604051639996b31560e01b81526001600160a01b038516600482015260240161080a565b5080610d86565b612e9e612a46565b611d6d81612f5f565b606081471015612ecc5760405163cd78605960e01b815230600482015260240161080a565b5f80856001600160a01b03168486604051612ee79190613980565b5f6040518083038185875af1925050503d805f8114612f21576040519150601f19603f3d011682016040523d82523d5f602084013e612f26565b606091505b509150915061288d868383612e3a565b805115612f465780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b611d3b612a46565b803561ffff81168114612f78575f80fd5b919050565b5f8083601f840112612f8d575f80fd5b5081356001600160401b03811115612fa3575f80fd5b602083019150836020828501011115612fba575f80fd5b9250929050565b80356001600160401b0381168114612f78575f80fd5b5f805f805f8060808789031215612fec575f80fd5b612ff587612f67565b955060208701356001600160401b0380821115613010575f80fd5b61301c8a838b01612f7d565b909750955085915061303060408a01612fc1565b94506060890135915080821115613045575f80fd5b5061305289828a01612f7d565b979a9699509497509295939492505050565b5f60208284031215613074575f80fd5b610d8682612f67565b5f806040838503121561308e575f80fd5b61309783612f67565b946020939093013593505050565b6001600160a01b0381168114611d6d575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b03811182821017156130f5576130f56130b9565b604052919050565b5f6001600160401b03821115613115576131156130b9565b50601f01601f191660200190565b5f82601f830112613132575f80fd5b8135613145613140826130fd565b6130cd565b818152846020838601011115613159575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215613188575f80fd5b61319185612f67565b935060208501356131a1816130a5565b92506040850135915060608501356001600160401b038111156131c2575f80fd5b6131ce87828801613123565b91505092959194509250565b5f805f604084860312156131ec575f80fd5b6131f584612f67565b925060208401356001600160401b0381111561320f575f80fd5b61321b86828701612f7d565b9497909650939450505050565b5f8060408385031215613239575f80fd5b8235613244816130a5565b915060208301356001600160401b0381111561325e575f80fd5b61326a85828601613123565b9150509250929050565b5f805f8060608587031215613287575f80fd5b61329085612f67565b935060208501356001600160401b038111156132aa575f80fd5b6132b687828801612f7d565b90945092506132c9905060408601612fc1565b905092959194509250565b5f5b838110156132ee5781810151838201526020016132d6565b50505f910152565b5f815180845261330d8160208601602086016132d4565b601f01601f19169290920160200192915050565b602081525f610d8660208301846132f6565b5f8060408385031215613344575f80fd5b61334d83612f67565b915061335b60208401612f67565b90509250929050565b5f60208284031215613374575f80fd5b8135610d86816130a5565b5f805f805f60808688031215613393575f80fd5b61339c86612f67565b94506133aa60208701612f67565b93506040860135925060608601356001600160401b038111156133cb575f80fd5b6133d788828901612f7d565b969995985093965092949392505050565b5f602082840312156133f8575f80fd5b5035919050565b5f8060408385031215613410575f80fd5b823561341b816130a5565b9150602083013561342b816130a5565b809150509250929050565b5f805f60608486031215613448575f80fd5b61345184612f67565b925061345f60208501612f67565b9150604084013590509250925092565b5f805f60608486031215613481575f80fd5b833561348c816130a5565b9250602084013561349c816130a5565b929592945050506040919091013590565b5f805f80608085870312156134c0575f80fd5b6134c985612f67565b93506134d760208601612f67565b925060408501356134e7816130a5565b9396929550929360600135925050565b600181811c9082168061350b57607f821691505b60208210810361352957634e487b7160e01b5f52602260045260245ffd5b50919050565b818382375f9101908152919050565b61ffff861681526001600160a01b038516602082015260a0604082018190525f9061356b908301866132f6565b8415156060840152828103608084015261358581856132f6565b98975050505050505050565b5f80604083850312156135a2575f80fd5b505080516020909101519092909150565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201525f611e146040830184866135b3565b634e487b7160e01b5f52601160045260245ffd5b81810381811115612d1157612d116135f8565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b601f821115612058575f81815260208120601f850160051c8101602086101561366b5750805b601f850160051c820191505b81811015610f9757828155600101613677565b81516001600160401b038111156136a3576136a36130b9565b6136b7816136b184546134f7565b84613645565b602080601f8311600181146136ea575f84156136d35750858301515b5f19600386901b1c1916600185901b178555610f97565b5f85815260208120601f198616915b82811015613718578886015182559484019460019091019084016136f9565b508582101561373557878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f61ffff8088168352808716602084015250846040830152608060608301526137726080830184866135b3565b979650505050505050565b61ffff86168152608060208201525f61379a6080830186886135b3565b6001600160401b0394909416604083015250606001529392505050565b6001600160401b038311156137ce576137ce6130b9565b6137e2836137dc83546134f7565b83613645565b5f601f841160018114613813575f85156137fc5750838201355b5f19600387901b1c1916600186901b178355610a3f565b5f83815260209020601f19861690835b828110156138435786850135825560209485019460019092019101613823565b508682101561385f575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b5f60208284031215613881575f80fd5b81516001600160401b03811115613896575f80fd5b8201601f810184136138a6575f80fd5b80516138b4613140826130fd565b8181528560208385010111156138c8575f80fd5b611e148260208301602086016132d4565b61ffff85168152608060208201525f6138f560808301866132f6565b6001600160401b0385166040840152828103606084015261377281856132f6565b5f60208284031215613926575f80fd5b5051919050565b5f805f6060848603121561393f575f80fd5b835161394a816130a5565b602085015190935061395b816130a5565b80925050604084015190509250925092565b80820180821115612d1157612d116135f8565b5f82516139918184602087016132d4565b9190910192915050565b61ffff8616815260a060208201525f6139b760a08301876132f6565b6001600160401b038616604084015282810360608401526139d881866132f6565b9050828103608084015261358581856132f6565b61ffff8716815260c060208201525f613a0860c08301886132f6565b8281036040840152613a1a81886132f6565b6001600160a01b0387811660608601528616608085015283810360a08501529050613a4581856132f6565b9998505050505050505050565b5f60208284031215613a62575f80fd5b81518015158114610d86575f80fdfeb6416d507a04e2a32445de45abf7290bf3bbe8e9fa76203447827b6ceacc5300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f003ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac216000f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00a26469706673582212203185bc939b618d3bebe77164d0a8b78a150bb08574271a79907dc32269de578064736f6c6343000815003300000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67500000000000000000000000000000000000000000000000000000000000000ed
Deployed Bytecode
0x60806040526004361061021c575f3560e01c80639f38369a1161011e578063cbed8b9c116100a8578063e5711e8b1161006d578063e5711e8b146106ed578063e9ee91071461070c578063eb8d72b71461072b578063f2fde38b1461074a578063f5ecbdbc14610769575f80fd5b8063cbed8b9c1461065e578063d1deba1f1461067d578063d583c12c14610690578063d60726e5146106af578063df2a5b3b146106ce575f80fd5b8063b353aaa7116100ee578063b353aaa7146105c4578063baf3292d146105f7578063c446183414610616578063c4ae31681461062b578063c4d66de81461063f575f80fd5b80639f38369a14610537578063a6c3d16514610556578063ab37f48614610575578063ad3cb1cc14610594575f80fd5b806352d1902d116101aa5780638cfd8f5c1161016f5780638cfd8f5c146104265780638da5cb5b146104845780638e4c3fe7146104d4578063950c8a74146104e8578063987fdcbe14610524575f80fd5b806352d1902d146103945780635b8c41e6146103a857806366ad5c8a146103c7578063715018a6146103e65780637533d788146103fa575f80fd5b806312e7d907116101f057806312e7d9071461029e5780633d8b38f6146102d75780633f1f4fa41461030657806342d65a8d146103625780634f1ef28614610381575f80fd5b80621d35671461022057806307e0db17146102415780630df374831461026057806310ddb1371461027f575b5f80fd5b34801561022b575f80fd5b5061023f61023a366004612fd7565b610788565b005b34801561024c575f80fd5b5061023f61025b366004613064565b6109c2565b34801561026b575f80fd5b5061023f61027a36600461307d565b610a46565b34801561028a575f80fd5b5061023f610299366004613064565b610a84565b3480156102a9575f80fd5b506102bd6102b8366004613175565b610adc565b604080519283526020830191909152015b60405180910390f35b3480156102e2575f80fd5b506102f66102f13660046131da565b610cb4565b60405190151581526020016102ce565b348015610311575f80fd5b50610354610320366004613064565b61ffff165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b02602052604090205490565b6040519081526020016102ce565b34801561036d575f80fd5b5061023f61037c3660046131da565b610d8d565b61023f61038f366004613228565b610e17565b34801561039f575f80fd5b50610354610e36565b3480156103b3575f80fd5b506103546103c2366004613274565b610e51565b3480156103d2575f80fd5b5061023f6103e1366004612fd7565b610ec5565b3480156103f1575f80fd5b5061023f610f9f565b348015610405575f80fd5b50610419610414366004613064565b610fb2565b6040516102ce9190613321565b348015610431575f80fd5b50610354610440366004613333565b61ffff9182165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b016020908152604080832093909416825291909152205490565b34801561048f575f80fd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b03165b6040516001600160a01b0390911681526020016102ce565b3480156104df575f80fd5b50610419611067565b3480156104f3575f80fd5b507f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b03546001600160a01b03166104bc565b61023f610532366004613175565b611127565b348015610542575f80fd5b50610419610551366004613064565b611316565b348015610561575f80fd5b5061023f6105703660046131da565b611436565b348015610580575f80fd5b506102f661058f366004613364565b6114ce565b34801561059f575f80fd5b50610419604051806040016040528060058152602001640352e302e360dc1b81525081565b3480156105cf575f80fd5b506104bc7f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67581565b348015610602575f80fd5b5061023f610611366004613364565b61150a565b348015610621575f80fd5b5061035461271081565b348015610636575f80fd5b5061023f611596565b34801561064a575f80fd5b5061023f610659366004613364565b6115ef565b348015610669575f80fd5b5061023f61067836600461337f565b6116f0565b61023f61068b366004612fd7565b611780565b34801561069b575f80fd5b5061023f6106aa3660046133e8565b61198d565b3480156106ba575f80fd5b5061023f6106c93660046133ff565b611a4d565b3480156106d9575f80fd5b5061023f6106e8366004613436565b611b15565b3480156106f8575f80fd5b5061023f61070736600461346f565b611bac565b348015610717575f80fd5b5061023f610726366004613364565b611c1a565b348015610736575f80fd5b5061023f6107453660046131da565b611ccb565b348015610755575f80fd5b5061023f610764366004613364565b611d33565b348015610774575f80fd5b506104196107833660046134ad565b611d70565b5f80516020613b12833981519152337f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316146108135760405162461bcd60e51b815260206004820152601e60248201527f4c7a4170703a20696e76616c696420656e64706f696e742063616c6c6572000060448201526064015b60405180910390fd5b61ffff87165f9081526020829052604081208054610830906134f7565b80601f016020809104026020016040519081016040528092919081815260200182805461085c906134f7565b80156108a75780601f1061087e576101008083540402835291602001916108a7565b820191905f5260205f20905b81548152906001019060200180831161088a57829003601f168201915b505050505090508051878790501480156108c15750805115155b80156108e95750805160208201206040516108df908990899061352f565b6040518091039020145b6109445760405162461bcd60e51b815260206004820152602660248201527f4c7a4170703a20696e76616c696420736f757263652073656e64696e6720636f6044820152651b9d1c9858dd60d21b606482015260840161080a565b6109b88888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525050604080516020601f8b018190048102820181019092528981528b9350915089908990819084018382808284375f92019190915250611e1d92505050565b5050505050505050565b6109ca611e95565b6040516307e0db1760e01b815261ffff821660048201527f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316906307e0db17906024015b5f604051808303815f87803b158015610a2d575f80fd5b505af1158015610a3f573d5f803e3d5ffd5b5050505050565b610a4e611e95565b61ffff919091165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b026020526040902055565b610a8c611e95565b6040516310ddb13760e01b815261ffff821660048201527f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b0316906310ddb13790602401610a16565b5f805f80516020613ad283398151915281610b1a876001600160a01b039081165f9081525f80516020613a7283398151915260205260409020541690565b90506001600160a01b038116610b435760405163d92e233d60e01b815260040160405180910390fd5b604080516001600160a01b03831660208201523381830152606080820189905282518083039091018152608090910190915285515f03610c0d57826001018054610b8c906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb8906134f7565b8015610c035780601f10610bda57610100808354040283529160200191610c03565b820191905f5260205f20905b815481529060010190602001808311610be657829003601f168201915b5050505050610c0f565b855b60405163040a7bb160e41b81529096506001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516906340a7bb1090610c66908c90309086905f908d9060040161353e565b6040805180830381865afa158015610c80573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ca49190613591565b9450945050505094509492505050565b61ffff83165f9081525f80516020613b128339815191526020819052604082208054839190610ce2906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054610d0e906134f7565b8015610d595780601f10610d3057610100808354040283529160200191610d59565b820191905f5260205f20905b815481529060010190602001808311610d3c57829003601f168201915b505050505090508484604051610d7092919061352f565b6040518091039020818051906020012014925050505b9392505050565b610d95611e95565b6040516342d65a8d60e01b81526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67516906342d65a8d90610de5908690869086906004016135db565b5f604051808303815f87803b158015610dfc575f80fd5b505af1158015610e0e573d5f803e3d5ffd5b50505050505050565b610e1f611ef0565b610e2882611f94565b610e328282611f9c565b5050565b5f610e3f61205d565b505f80516020613a9283398151915290565b61ffff84165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600602081905260408083209051610e94908790879061352f565b908152604080519182900360209081019092206001600160401b0386165f9081529252902054915050949350505050565b333014610f235760405162461bcd60e51b815260206004820152602660248201527f4e6f6e626c6f636b696e674c7a4170703a2063616c6c6572206d7573742062656044820152650204c7a4170760d41b606482015260840161080a565b610f978686868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525050604080516020601f8901819004810282018101909252878152899350915087908790819084018382808284375f920191909152506120a692505050565b505050505050565b610fa7611e95565b610fb05f612177565b565b61ffff81165f9081525f80516020613b128339815191526020819052604090912080546060929190610fe3906134f7565b80601f016020809104026020016040519081016040528092919081815260200182805461100f906134f7565b801561105a5780601f106110315761010080835404028352916020019161105a565b820191905f5260205f20905b81548152906001019060200180831161103d57829003601f168201915b5050505050915050919050565b7f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600180546060915f80516020613ad2833981519152916110a5906134f7565b80601f01602080910402602001604051908101604052809291908181526020018280546110d1906134f7565b801561111c5780601f106110f35761010080835404028352916020019161111c565b820191905f5260205f20905b8154815290600101906020018083116110ff57829003601f168201915b505050505091505090565b61112f6121e7565b5f80516020613ad2833981519152805460ff161561116057604051631309a56360e01b815260040160405180910390fd5b6001600160a01b0384166111875760405163d92e233d60e01b815260040160405180910390fd5b825f036111a757604051633494a40d60e21b815260040160405180910390fd5b6001600160a01b0384165f9081527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600260205260409020545f80516020613ad28339815191529060ff1661120d5760405163514e24c360e11b815260040160405180910390fd5b82515f036112a557806001018054611224906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054611250906134f7565b801561129b5780601f106112725761010080835404028352916020019161129b565b820191905f5260205f20905b81548152906001019060200180831161127e57829003601f168201915b50505050506112a7565b825b92506112b58686868661221e565b846001600160a01b03167faace68a8a572e895e6d32578e0225016942d4c7734b4574a5e26fffce5eb7754856040516112f091815260200190565b60405180910390a2505061131060015f80516020613ab283398151915255565b50505050565b61ffff81165f9081525f80516020613b1283398151915260208190526040822080546060939190611346906134f7565b80601f0160208091040260200160405190810160405280929190818152602001828054611372906134f7565b80156113bd5780601f10611394576101008083540402835291602001916113bd565b820191905f5260205f20905b8154815290600101906020018083116113a057829003601f168201915b5050505050905080515f036114145760405162461bcd60e51b815260206004820152601d60248201527f4c7a4170703a206e6f20747275737465642070617468207265636f7264000000604482015260640161080a565b61142e5f60148351611426919061360c565b8391906122e7565b949350505050565b61143e611e95565b6040515f80516020613b12833981519152906114629084908490309060200161361f565b60408051601f1981840301815291815261ffff86165f9081526020849052209061148c908261368a565b507f8c0400cfe2d1199b1a725c78960bcc2a344d869b80590d0f2bd005db15a572ce8484846040516114c0939291906135db565b60405180910390a150505050565b6001600160a01b03165f9081527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac216002602052604090205460ff1690565b611512611e95565b7f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0380546001600160a01b0319166001600160a01b0383169081179091556040519081525f80516020613b12833981519152907f5db758e995a17ec1ad84bdef7e8c3293a0bd6179bcce400dff5d4c3d87db726b906020015b60405180910390a15050565b61159e611e95565b5f80516020613ad2833981519152805460ff8116801560ff1990921682178355604051918252907f0e2fb031ee032dc02d8011dc50b816eb450cf856abd8261680dac74f72165bd29060200161158a565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f811580156116205750825b90505f826001600160401b0316600114801561163b5750303b155b905081158015611649575080155b156116675760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561169157845460ff60401b1916600160401b1785555b6116996123f3565b6116a2866123fb565b8315610f9757845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2906020015b60405180910390a1505050505050565b6116f8611e95565b6040516332fb62e760e21b81526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675169063cbed8b9c9061174c9088908890889088908890600401613745565b5f604051808303815f87803b158015611763575f80fd5b505af1158015611775573d5f803e3d5ffd5b505050505050505050565b61ffff86165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d86006020819052604080832090519192916117c6908990899061352f565b90815260408051602092819003830190206001600160401b0388165f90815292819052912054909150806118485760405162461bcd60e51b815260206004820152602360248201527f4e6f6e626c6f636b696e674c7a4170703a206e6f2073746f726564206d65737360448201526261676560e81b606482015260840161080a565b80858560405161185992919061352f565b6040518091039020146118b85760405162461bcd60e51b815260206004820152602160248201527f4e6f6e626c6f636b696e674c7a4170703a20696e76616c6964207061796c6f616044820152601960fa1b606482015260840161080a565b6001600160401b0386165f90815260208381526040808320929092558151601f8a01829004820281018201909252888252611943918b918b908b90819084018382808284375f9201919091525050604080516020601f8c018190048102820181019092528a81528c935091508a908a90819084018382808284375f920191909152506120a692505050565b7fc264d91f3adc5588250e1551f547752ca0cfa8f6b530d243b9f9f4cab10ea8e5898989898560405161197a95949392919061377d565b60405180910390a1505050505050505050565b611995611e95565b62030d408110156119b957604051633494a40d60e21b815260040160405180910390fd5b60408051600160f01b602082015260228082018490528251808303909101815260429091019091525f80516020613ad2833981519152907f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac21600190611a1c908261368a565b506040518281527f662c05f57b360ad4fcbac92752d55be66104d4a8a0602bdbac3183da2019f6409060200161158a565b611a55611e95565b6001600160a01b0382161580611a7257506001600160a01b038116155b15611a905760405163d92e233d60e01b815260040160405180910390fd5b611a9b8260016124b6565b6001600160a01b038281165f8181525f80516020613a728339815191526020819052604080832080546001600160a01b031990811696881696871790915585845281842080549091168517905551909392917fabd9ef659885734886a5f10f58870113f8b657716ae8cd4a5eed6babba9d7b0791a3505050565b611b1d611e95565b61ffff8381165f8181527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b01602090815260408083209487168084529482529182902085905581519283528201929092529081018290525f80516020613b12833981519152907f9d5c7c0b934da8fefa9c7760c98383778a12dfbfc0c3b3106518f43fb9508ac0906060016114c0565b611bb4611e95565b611bc86001600160a01b0384168383612544565b816001600160a01b0316836001600160a01b03167f4143f7b5cb6ea007914c32b8a3e64cebc051d7f493fa0755454da1e47701e12583604051611c0d91815260200190565b60405180910390a3505050565b611c22611e95565b6001600160a01b038116611c495760405163d92e233d60e01b815260040160405180910390fd5b611c53815f6124b6565b6001600160a01b038181165f8181525f80516020613a728339815191526020819052604080832080546001600160a01b0319808216909255909516808452818420805490961690955551909392907fabd9ef659885734886a5f10f58870113f8b657716ae8cd4a5eed6babba9d7b07908390a3505050565b611cd3611e95565b61ffff83165f9081525f80516020613b1283398151915260208190526040909120611cff8385836137b7565b507ffa41487ad5d6728f0b19276fa1eddc16558578f5109fc39d2dc33c3230470dab8484846040516114c0939291906135db565b611d3b611e95565b6001600160a01b038116611d6457604051631e4fbdf760e01b81525f600482015260240161080a565b611d6d81612177565b50565b604051633d7b2f6f60e21b815261ffff808616600483015284166024820152306044820152606481018290526060907f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd6756001600160a01b03169063f5ecbdbc906084015f60405180830381865afa158015611ded573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611e149190810190613871565b95945050505050565b5f80611e7f5a60966366ad5c8a60e01b89898989604051602401611e4494939291906138d9565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152309291906125a3565b9150915081610f9757610f978686868685612627565b33611ec77f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300546001600160a01b031690565b6001600160a01b031614610fb05760405163118cdaa760e01b815233600482015260240161080a565b306001600160a01b037f00000000000000000000000055cca4da8d7bf879fd0ca04d16aa69f18b419704161480611f7657507f00000000000000000000000055cca4da8d7bf879fd0ca04d16aa69f18b4197046001600160a01b0316611f6a5f80516020613a92833981519152546001600160a01b031690565b6001600160a01b031614155b15610fb05760405163703e46dd60e11b815260040160405180910390fd5b611d6d611e95565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611ff6575060408051601f3d908101601f19168201909252611ff391810190613916565b60015b61201e57604051634c9c8ce360e01b81526001600160a01b038316600482015260240161080a565b5f80516020613a92833981519152811461204e57604051632a87526960e21b81526004810182905260240161080a565b61205883836126cf565b505050565b306001600160a01b037f00000000000000000000000055cca4da8d7bf879fd0ca04d16aa69f18b4197041614610fb05760405163703e46dd60e11b815260040160405180910390fd5b6120ae6121e7565b5f80516020613ad2833981519152805460ff16156120df57604051631309a56360e01b815260040160405180910390fd5b5f805f848060200190518101906120f6919061392d565b9250925092505f612108848484612724565b9050826001600160a01b0316816001600160a01b03168a61ffff167f2d5ac612d9c6868638a5cda69e2027394838483929e459f2e99ad9c413bf3ad78560405161215491815260200190565b60405180910390a4505050505061131060015f80516020613ab283398151915255565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f80516020613ab283398151915280546001190161221857604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b61222a83333085612795565b9150815f0361224c5760405163162908e360e11b815260040160405180910390fd5b6001600160a01b038381165f9081525f80516020613a728339815191526020818152604092839020548351941690840181905233848401819052606080860188905284518087039091018152608090950190935290929091610e0e907f00000000000000000000000000000000000000000000000000000000000000ed9083905f8834612897565b60015f80516020613ab283398151915255565b6060816122f581601f61396d565b10156123345760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b604482015260640161080a565b61233e828461396d565b845110156123825760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b604482015260640161080a565b6060821580156123a05760405191505f8252602082016040526123ea565b6040519150601f8416801560200281840101858101878315602002848b0101015b818310156123d95780518352602092830192016123c1565b5050858452601f01601f1916604052505b50949350505050565b610fb0612a46565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f8115801561242c5750825b90505f826001600160401b031660011480156124475750303b155b905081158015612455575080155b156124735760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561249d57845460ff60401b1916600160401b1785555b6124a5612a7c565b6124ae86612a8c565b6116a2612aa5565b6001600160a01b0382165f8181527f3ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac2160026020908152604091829020805460ff191685151590811790915591519182525f80516020613ad283398151915292917fa54714518c5d275fdcd3d2a461e4858e4e8cb04fb93cd0bca9d6d34115f26440910160405180910390a2505050565b6040516001600160a01b0383811660248301526044820183905261205891859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612bdf565b5f60605f805f8661ffff166001600160401b038111156125c5576125c56130b9565b6040519080825280601f01601f1916602001820160405280156125ef576020820181803683370190505b5090505f808751602089015f8d8df191503d92508683111561260f578692505b828152825f602083013e909890975095505050505050565b815160208084019190912061ffff87165f9081527fe5a86fa43fa85f564c84895bd4f80ec5c29d03a57a0c1f7cb91d2cc05b4d8600928390526040908190209051612673908890613980565b9081526040805191829003602090810183206001600160401b0389165f908152915220919091557fe183f33de2837795525b4792ca4cd60535bd77c53b7e7030060bfcf5734d6b0c906116e0908890889088908890889061399b565b6126d882612c40565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a280511561271c576120588282612ca3565b610e32612d17565b6001600160a01b038381165f9081525f80516020613a728339815191526020819052604082205491929091168015806127635750612761816114ce565b155b156127815760405163514e24c360e11b815260040160405180910390fd5b611e146001600160a01b0382168686612544565b6040516370a0823160e01b81526001600160a01b0383811660048301525f9182918716906370a0823190602401602060405180830381865afa1580156127dd573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128019190613916565b90506128186001600160a01b038716868686612d36565b6040516370a0823160e01b81526001600160a01b0385811660048301528291908816906370a0823190602401602060405180830381865afa15801561285f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906128839190613916565b61288d919061360c565b9695505050505050565b61ffff86165f9081525f80516020613b1283398151915260208190526040822080549192916128c5906134f7565b80601f01602080910402602001604051908101604052809291908181526020018280546128f1906134f7565b801561293c5780601f106129135761010080835404028352916020019161293c565b820191905f5260205f20905b81548152906001019060200180831161291f57829003601f168201915b5050505050905080515f036129ac5760405162461bcd60e51b815260206004820152603060248201527f4c7a4170703a2064657374696e6174696f6e20636861696e206973206e6f742060448201526f61207472757374656420736f7572636560801b606482015260840161080a565b6129b7888851612d6f565b60405162c5803160e81b81526001600160a01b037f00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675169063c5803100908590612a0e908c9086908d908d908d908d906004016139ec565b5f604051808303818588803b158015612a25575f80fd5b505af1158015612a37573d5f803e3d5ffd5b50505050505050505050505050565b5f80516020613af283398151915254600160401b900460ff16610fb057604051631afcd79f60e31b815260040160405180910390fd5b612a84612a46565b610fb0612e0c565b612a94612a46565b612a9c6123f3565b611d6d81612e14565b5f80516020613af28339815191528054600160401b810460ff1615906001600160401b03165f81158015612ad65750825b90505f826001600160401b03166001148015612af15750303b155b905081158015612aff575080155b15612b1d5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315612b4757845460ff60401b1916600160401b1785555b5f5f80516020613ad2833981519152604051600160f01b602082015262030d406022820152909150604201604051602081830303815290604052816001019081612b91919061368a565b50508315610a3f57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050565b5f612bf36001600160a01b03841683612e2d565b905080515f14158015612c17575080806020019051810190612c159190613a52565b155b1561205857604051635274afe760e01b81526001600160a01b038416600482015260240161080a565b806001600160a01b03163b5f03612c7557604051634c9c8ce360e01b81526001600160a01b038216600482015260240161080a565b5f80516020613a9283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b60605f80846001600160a01b031684604051612cbf9190613980565b5f60405180830381855af49150503d805f8114612cf7576040519150601f19603f3d011682016040523d82523d5f602084013e612cfc565b606091505b5091509150612d0c858383612e3a565b925050505b92915050565b3415610fb05760405163b398979f60e01b815260040160405180910390fd5b6040516001600160a01b0384811660248301528381166044830152606482018390526113109186918216906323b872dd90608401612571565b61ffff82165f9081527f111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b0260205260408120545f80516020613b1283398151915291819003612dbc57506127105b808311156113105760405162461bcd60e51b815260206004820181905260248201527f4c7a4170703a207061796c6f61642073697a6520697320746f6f206c61726765604482015260640161080a565b6122d4612a46565b612e1c612a46565b612e246123f3565b611d6d81612e96565b6060610d8683835f612ea7565b606082612e4f57612e4a82612f36565b610d86565b8151158015612e6657506001600160a01b0384163b155b15612e8f57604051639996b31560e01b81526001600160a01b038516600482015260240161080a565b5080610d86565b612e9e612a46565b611d6d81612f5f565b606081471015612ecc5760405163cd78605960e01b815230600482015260240161080a565b5f80856001600160a01b03168486604051612ee79190613980565b5f6040518083038185875af1925050503d805f8114612f21576040519150601f19603f3d011682016040523d82523d5f602084013e612f26565b606091505b509150915061288d868383612e3a565b805115612f465780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b611d3b612a46565b803561ffff81168114612f78575f80fd5b919050565b5f8083601f840112612f8d575f80fd5b5081356001600160401b03811115612fa3575f80fd5b602083019150836020828501011115612fba575f80fd5b9250929050565b80356001600160401b0381168114612f78575f80fd5b5f805f805f8060808789031215612fec575f80fd5b612ff587612f67565b955060208701356001600160401b0380821115613010575f80fd5b61301c8a838b01612f7d565b909750955085915061303060408a01612fc1565b94506060890135915080821115613045575f80fd5b5061305289828a01612f7d565b979a9699509497509295939492505050565b5f60208284031215613074575f80fd5b610d8682612f67565b5f806040838503121561308e575f80fd5b61309783612f67565b946020939093013593505050565b6001600160a01b0381168114611d6d575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b03811182821017156130f5576130f56130b9565b604052919050565b5f6001600160401b03821115613115576131156130b9565b50601f01601f191660200190565b5f82601f830112613132575f80fd5b8135613145613140826130fd565b6130cd565b818152846020838601011115613159575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215613188575f80fd5b61319185612f67565b935060208501356131a1816130a5565b92506040850135915060608501356001600160401b038111156131c2575f80fd5b6131ce87828801613123565b91505092959194509250565b5f805f604084860312156131ec575f80fd5b6131f584612f67565b925060208401356001600160401b0381111561320f575f80fd5b61321b86828701612f7d565b9497909650939450505050565b5f8060408385031215613239575f80fd5b8235613244816130a5565b915060208301356001600160401b0381111561325e575f80fd5b61326a85828601613123565b9150509250929050565b5f805f8060608587031215613287575f80fd5b61329085612f67565b935060208501356001600160401b038111156132aa575f80fd5b6132b687828801612f7d565b90945092506132c9905060408601612fc1565b905092959194509250565b5f5b838110156132ee5781810151838201526020016132d6565b50505f910152565b5f815180845261330d8160208601602086016132d4565b601f01601f19169290920160200192915050565b602081525f610d8660208301846132f6565b5f8060408385031215613344575f80fd5b61334d83612f67565b915061335b60208401612f67565b90509250929050565b5f60208284031215613374575f80fd5b8135610d86816130a5565b5f805f805f60808688031215613393575f80fd5b61339c86612f67565b94506133aa60208701612f67565b93506040860135925060608601356001600160401b038111156133cb575f80fd5b6133d788828901612f7d565b969995985093965092949392505050565b5f602082840312156133f8575f80fd5b5035919050565b5f8060408385031215613410575f80fd5b823561341b816130a5565b9150602083013561342b816130a5565b809150509250929050565b5f805f60608486031215613448575f80fd5b61345184612f67565b925061345f60208501612f67565b9150604084013590509250925092565b5f805f60608486031215613481575f80fd5b833561348c816130a5565b9250602084013561349c816130a5565b929592945050506040919091013590565b5f805f80608085870312156134c0575f80fd5b6134c985612f67565b93506134d760208601612f67565b925060408501356134e7816130a5565b9396929550929360600135925050565b600181811c9082168061350b57607f821691505b60208210810361352957634e487b7160e01b5f52602260045260245ffd5b50919050565b818382375f9101908152919050565b61ffff861681526001600160a01b038516602082015260a0604082018190525f9061356b908301866132f6565b8415156060840152828103608084015261358581856132f6565b98975050505050505050565b5f80604083850312156135a2575f80fd5b505080516020909101519092909150565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b61ffff84168152604060208201525f611e146040830184866135b3565b634e487b7160e01b5f52601160045260245ffd5b81810381811115612d1157612d116135f8565b8284823760609190911b6bffffffffffffffffffffffff19169101908152601401919050565b601f821115612058575f81815260208120601f850160051c8101602086101561366b5750805b601f850160051c820191505b81811015610f9757828155600101613677565b81516001600160401b038111156136a3576136a36130b9565b6136b7816136b184546134f7565b84613645565b602080601f8311600181146136ea575f84156136d35750858301515b5f19600386901b1c1916600185901b178555610f97565b5f85815260208120601f198616915b82811015613718578886015182559484019460019091019084016136f9565b508582101561373557878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b5f61ffff8088168352808716602084015250846040830152608060608301526137726080830184866135b3565b979650505050505050565b61ffff86168152608060208201525f61379a6080830186886135b3565b6001600160401b0394909416604083015250606001529392505050565b6001600160401b038311156137ce576137ce6130b9565b6137e2836137dc83546134f7565b83613645565b5f601f841160018114613813575f85156137fc5750838201355b5f19600387901b1c1916600186901b178355610a3f565b5f83815260209020601f19861690835b828110156138435786850135825560209485019460019092019101613823565b508682101561385f575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b5f60208284031215613881575f80fd5b81516001600160401b03811115613896575f80fd5b8201601f810184136138a6575f80fd5b80516138b4613140826130fd565b8181528560208385010111156138c8575f80fd5b611e148260208301602086016132d4565b61ffff85168152608060208201525f6138f560808301866132f6565b6001600160401b0385166040840152828103606084015261377281856132f6565b5f60208284031215613926575f80fd5b5051919050565b5f805f6060848603121561393f575f80fd5b835161394a816130a5565b602085015190935061395b816130a5565b80925050604084015190509250925092565b80820180821115612d1157612d116135f8565b5f82516139918184602087016132d4565b9190910192915050565b61ffff8616815260a060208201525f6139b760a08301876132f6565b6001600160401b038616604084015282810360608401526139d881866132f6565b9050828103608084015261358581856132f6565b61ffff8716815260c060208201525f613a0860c08301886132f6565b8281036040840152613a1a81886132f6565b6001600160a01b0387811660608601528616608085015283810360a08501529050613a4581856132f6565b9998505050505050505050565b5f60208284031215613a62575f80fd5b81518015158114610d86575f80fdfeb6416d507a04e2a32445de45abf7290bf3bbe8e9fa76203447827b6ceacc5300360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f003ae64415efeba844fa889963cef544e4188d2a0d9305c2abef15a53cac216000f0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00111388274dd962a0529050efb131321f60015c2ab1a99387d94540f430037b00a26469706673582212203185bc939b618d3bebe77164d0a8b78a150bb08574271a79907dc32269de578064736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd67500000000000000000000000000000000000000000000000000000000000000ed
-----Decoded View---------------
Arg [0] : endpoint_ (address): 0x66A71Dcef29A0fFBDBE3c6a460a3B5BC225Cd675
Arg [1] : dstChainId_ (uint16): 237
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000066a71dcef29a0ffbdbe3c6a460a3b5bc225cd675
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000ed
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.