Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Name:
EqbMinterSidechain
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import "./EqbMinterBaseUpg.sol"; contract EqbMinterSidechain is EqbMinterBaseUpg { uint256 public factor; event FactorUpdated(uint256 _factor); event MintedAmountBroadcasted(uint256[] _chainIds, uint256 _amount); function initialize( address _eqb, address _eqbMsgSendEndpoint, uint256 _approxDstExecutionGas, address _eqbMsgReceiveEndpoint ) public initializer { __EqbMinterBase_init( _eqb, _eqbMsgSendEndpoint, _approxDstExecutionGas, _eqbMsgReceiveEndpoint ); factor = DENOMINATOR; emit FactorUpdated(DENOMINATOR); } function broadcastMintedAmount( uint256[] calldata _chainIds ) public payable refundUnusedEth { if (_chainIds.length == 0) { revert Errors.ArrayEmpty(); } for (uint256 i = 0; i < _chainIds.length; i++) { _sendMessage(_chainIds[i], abi.encode(mintedAmount)); } emit MintedAmountBroadcasted(_chainIds, mintedAmount); } function _executeMessage( uint256, address, bytes memory _message ) internal override { factor = abi.decode(_message, (uint256)); emit FactorUpdated(factor); } function getFactor() public view override returns (uint256) { return factor; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableMap.sol) pragma solidity ^0.8.0; import "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32`) since v4.6.0 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0 * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an array of EnumerableMap. * ==== */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value ) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function get( Bytes32ToBytes32Map storage map, bytes32 key, string memory errorMessage ) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), errorMessage); return value; } // UintToUintMap struct UintToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToUintMap storage map, uint256 key, uint256 value ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToUintMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToUintMap storage map, uint256 key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( UintToAddressMap storage map, uint256 key, address value ) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage)))); } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( AddressToUintMap storage map, address key, uint256 value ) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (address(uint160(uint256(key))), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( AddressToUintMap storage map, address key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage)); } // Bytes32ToUintMap struct Bytes32ToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set( Bytes32ToUintMap storage map, bytes32 key, uint256 value ) internal returns (bool) { return set(map._inner, key, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the set. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (key, uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, key); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) { return uint256(get(map._inner, key)); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( Bytes32ToUintMap storage map, bytes32 key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, key, errorMessage)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../Interfaces/IEqbMsgReceiver.sol"; import "../Dependencies/Errors.sol"; abstract contract EqbMsgReceiverUpg is IEqbMsgReceiver, OwnableUpgradeable { address public eqbMsgReceiveEndpoint; uint256[100] private __gap; modifier onlyFromEqbMsgReceiveEndpoint() { if (msg.sender != eqbMsgReceiveEndpoint) revert Errors.MsgNotFromReceiveEndpoint(msg.sender); _; } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function __EqbMsgReceiver_init( address _eqbMsgReceiveEndpoint ) internal onlyInitializing { __EqbMsgReceiver_init_unchained(_eqbMsgReceiveEndpoint); } function __EqbMsgReceiver_init_unchained( address _eqbMsgReceiveEndpoint ) internal onlyInitializing { __Ownable_init_unchained(); eqbMsgReceiveEndpoint = _eqbMsgReceiveEndpoint; } function setEqbMsgReceiveEndpoint( address _eqbMsgReceiveEndpoint ) external onlyOwner { eqbMsgReceiveEndpoint = _eqbMsgReceiveEndpoint; } function executeMessage( uint256 _srcChainId, address _srcAddr, bytes calldata _message ) external virtual onlyFromEqbMsgReceiveEndpoint { _executeMessage(_srcChainId, _srcAddr, _message); } function _executeMessage( uint256 _srcChainId, address _srcAddr, bytes memory _message ) internal virtual; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../Interfaces/IEqbMsgSendEndpoint.sol"; import "../Dependencies/Errors.sol"; abstract contract EqbMsgSenderUpg is OwnableUpgradeable { using EnumerableMap for EnumerableMap.UintToAddressMap; IEqbMsgSendEndpoint public eqbMsgSendEndpoint; uint256 public approxDstExecutionGas; // destinationContracts mapping contains one address for each chainId only EnumerableMap.UintToAddressMap internal destinationContracts; uint256[100] private __gap; event MsgSent(uint256 indexed _chainId, bytes _message); modifier refundUnusedEth() { _; if (address(this).balance > 0) { AddressUpgradeable.sendValue( payable(msg.sender), address(this).balance ); } } /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function __EqbMsgSender_init( address _eqbMsgSendEndpoint, uint256 _approxDstExecutionGas ) internal onlyInitializing { __EqbMsgSender_init_unchained( _eqbMsgSendEndpoint, _approxDstExecutionGas ); } function __EqbMsgSender_init_unchained( address _eqbMsgSendEndpoint, uint256 _approxDstExecutionGas ) internal onlyInitializing { __Ownable_init_unchained(); eqbMsgSendEndpoint = IEqbMsgSendEndpoint(_eqbMsgSendEndpoint); approxDstExecutionGas = _approxDstExecutionGas; } function _sendMessage(uint256 _chainId, bytes memory _message) internal { assert(destinationContracts.contains(_chainId)); address toAddr = destinationContracts.get(_chainId); uint256 estimatedGasAmount = approxDstExecutionGas; uint256 fee = eqbMsgSendEndpoint.calcFee( _chainId, toAddr, _message, estimatedGasAmount ); // LM contracts won't hold ETH on its own so this is fine if (address(this).balance < fee) { revert Errors.InsufficientFeeToSendMsg(address(this).balance, fee); } eqbMsgSendEndpoint.sendMessage{value: fee}( _chainId, toAddr, _message, estimatedGasAmount ); emit MsgSent(_chainId, _message); } function addDestinationContract( uint256 _chainId, address _address ) external payable onlyOwner { destinationContracts.set(_chainId, _address); } function setApproxDstExecutionGas(uint256 _gas) external onlyOwner { approxDstExecutionGas = _gas; } function getAllDestinationContracts() public view returns (uint256[] memory chainIds, address[] memory addrs) { uint256 length = destinationContracts.length(); chainIds = new uint256[](length); addrs = new address[](length); for (uint256 i = 0; i < length; ++i) { (chainIds[i], addrs[i]) = destinationContracts.at(i); } } function _getSendMessageFee( uint256 chainId, bytes memory message ) internal view returns (uint256) { return eqbMsgSendEndpoint.calcFee( chainId, destinationContracts.get(chainId), message, approxDstExecutionGas ); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; library Errors { error ArrayEmpty(); error InsufficientBalance(uint256 balance, uint256 required); error InvalidMerkleProof(); error InvalidAmount(uint256 amount); // Lybra error InvalidVault(address _vault); error InvalidDepositAmount(uint256 amount); // cross chain error InsufficientFeeToSendMsg(uint256 currentFee, uint256 requiredFee); error OnlyLayerZeroEndpoint(); error MsgNotFromSendEndpoint(uint16 srcChainId, bytes path); error MsgNotFromReceiveEndpoint(address sender); error OnlyWhitelisted(); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./CrossChain/EqbMsgSenderUpg.sol"; import "./CrossChain/EqbMsgReceiverUpg.sol"; import "./Dependencies/Errors.sol"; import "./Interfaces/IEqbMinter.sol"; abstract contract EqbMinterBaseUpg is IEqbMinter, EqbMsgSenderUpg, EqbMsgReceiverUpg { using SafeERC20 for IERC20; address public eqb; uint256 public constant DENOMINATOR = 10000; uint256 public mintedAmount; mapping(address => bool) public access; uint256[100] private __gap; /// @custom:oz-upgrades-unsafe-allow constructor constructor() { _disableInitializers(); } function __EqbMinterBase_init( address _eqb, address _eqbMsgSendEndpoint, uint256 _approxDstExecutionGas, address _eqbMsgReceiveEndpoint ) internal onlyInitializing { __EqbMinterBase_init_unchained( _eqb, _eqbMsgSendEndpoint, _approxDstExecutionGas, _eqbMsgReceiveEndpoint ); } function __EqbMinterBase_init_unchained( address _eqb, address _eqbMsgSendEndpoint, uint256 _approxDstExecutionGas, address _eqbMsgReceiveEndpoint ) internal onlyInitializing { __EqbMsgSender_init_unchained( _eqbMsgSendEndpoint, _approxDstExecutionGas ); __EqbMsgReceiver_init_unchained(_eqbMsgReceiveEndpoint); eqb = _eqb; } function setAccess(address _operator, bool _access) external onlyOwner { require(_operator != address(0), "invalid _operator!"); access[_operator] = _access; emit AccessUpdated(_operator, _access); } function mint(address _to, uint256 _amount) external returns (uint256) { require(access[msg.sender], "!auth"); uint256 mintAmount = (_amount * getFactor()) / DENOMINATOR; uint256 eqbBal = IERC20(eqb).balanceOf(address(this)); if (eqbBal < mintAmount) { revert Errors.InsufficientBalance(eqbBal, mintAmount); } IERC20(eqb).safeTransfer(_to, mintAmount); mintedAmount += mintAmount; _afterMint(); emit MintedAmountUpdated(mintedAmount); emit Minted(_to, mintAmount); return mintAmount; } function _afterMint() internal virtual {} function getFactor() public view virtual returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; interface IEqbMinter { function mint(address _to, uint256 _amount) external returns (uint256); event Minted(address indexed _to, uint256 _amount); event MintedAmountUpdated(uint256 _amount); event AccessUpdated(address _operator, bool _access); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; interface IEqbMsgReceiver { function executeMessage( uint256 _srcChainId, address _srcAddr, bytes calldata _message ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.17; interface IEqbMsgSendEndpoint { function calcFee( uint256 _dstChainId, address _dstAddress, bytes memory _payload, uint256 _estimatedGasAmount ) external view returns (uint256 fee); function sendMessage( uint256 _dstChainId, address _dstAddress, bytes calldata _payload, uint256 _estimatedGasAmount ) external payable; event MsgSent( uint256 _dstChainId, address _dstAddress, bytes _payload, uint256 _estimatedGasAmount ); }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"ArrayEmpty","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"required","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[{"internalType":"uint256","name":"currentFee","type":"uint256"},{"internalType":"uint256","name":"requiredFee","type":"uint256"}],"name":"InsufficientFeeToSendMsg","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"MsgNotFromReceiveEndpoint","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_operator","type":"address"},{"indexed":false,"internalType":"bool","name":"_access","type":"bool"}],"name":"AccessUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_factor","type":"uint256"}],"name":"FactorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Minted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"_chainIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"MintedAmountBroadcasted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"MintedAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_chainId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"_message","type":"bytes"}],"name":"MsgSent","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"},{"inputs":[],"name":"DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"access","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_chainId","type":"uint256"},{"internalType":"address","name":"_address","type":"address"}],"name":"addDestinationContract","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"approxDstExecutionGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_chainIds","type":"uint256[]"}],"name":"broadcastMintedAmount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eqb","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eqbMsgReceiveEndpoint","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"eqbMsgSendEndpoint","outputs":[{"internalType":"contract IEqbMsgSendEndpoint","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_srcChainId","type":"uint256"},{"internalType":"address","name":"_srcAddr","type":"address"},{"internalType":"bytes","name":"_message","type":"bytes"}],"name":"executeMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"factor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllDestinationContracts","outputs":[{"internalType":"uint256[]","name":"chainIds","type":"uint256[]"},{"internalType":"address[]","name":"addrs","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_eqb","type":"address"},{"internalType":"address","name":"_eqbMsgSendEndpoint","type":"address"},{"internalType":"uint256","name":"_approxDstExecutionGas","type":"uint256"},{"internalType":"address","name":"_eqbMsgReceiveEndpoint","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"bool","name":"_access","type":"bool"}],"name":"setAccess","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gas","type":"uint256"}],"name":"setApproxDstExecutionGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_eqbMsgReceiveEndpoint","type":"address"}],"name":"setEqbMsgReceiveEndpoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000036565b6200002662000036565b6200003062000036565b620000f8565b600054610100900460ff1615620000a35760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000f6576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b611c4280620001086000396000f3fe60806040526004361061016a5760003560e01c8063715018a6116100cb578063b84614a51161007f578063d65b394311610059578063d65b3943146103aa578063dd64e57c146103ca578063f2fde38b146103ea57600080fd5b8063b84614a51461034a578063be2030941461036a578063d45f5e211461038a57600080fd5b80638da5cb5b116100b05780638da5cb5b14610300578063918f86741461031e5780639efc75751461033457600080fd5b8063715018a6146102d8578063799233e4146102ed57600080fd5b80635dbd1688116101225780636349d251116101075780636349d2511461023e578063646fcdd2146102765780636fae3d761461029757600080fd5b80635dbd1688146102095780635edf676c1461022b57600080fd5b806340c10f191161015357806340c10f19146101bc5780635184cc43146101dc57806354f703f8146101f257600080fd5b80632d3802421461016f5780633e39b65014610199575b600080fd5b34801561017b57600080fd5b506101866101345481565b6040519081526020015b60405180910390f35b3480156101a557600080fd5b506101ae61040a565b604051610190929190611752565b3480156101c857600080fd5b506101866101d73660046117f2565b610520565b3480156101e857600080fd5b5061019a54610186565b3480156101fe57600080fd5b5061018661019a5481565b34801561021557600080fd5b5061022961022436600461181c565b610739565b005b610229610239366004611837565b610770565b34801561024a57600080fd5b5060655461025e906001600160a01b031681565b6040516001600160a01b039091168152602001610190565b34801561028257600080fd5b506101335461025e906001600160a01b031681565b3480156102a357600080fd5b506102c86102b236600461181c565b6101356020526000908152604090205460ff1681565b6040519015158152602001610190565b3480156102e457600080fd5b50610229610861565b6102296102fb3660046118ac565b610875565b34801561030c57600080fd5b506033546001600160a01b031661025e565b34801561032a57600080fd5b5061018661271081565b34801561034057600080fd5b5061018660665481565b34801561035657600080fd5b506102296103653660046118e6565b61088e565b34801561037657600080fd5b5061022961038536600461191d565b610950565b34801561039657600080fd5b506102296103a536600461196a565b610ab4565b3480156103b657600080fd5b5060ce5461025e906001600160a01b031681565b3480156103d657600080fd5b506102296103e5366004611983565b610ac1565b3480156103f657600080fd5b5061022961040536600461181c565b610b4e565b60608060006104196067610bde565b90508067ffffffffffffffff81111561043457610434611a0a565b60405190808252806020026020018201604052801561045d578160200160208202803683370190505b5092508067ffffffffffffffff81111561047957610479611a0a565b6040519080825280602002602001820160405280156104a2578160200160208202803683370190505b50915060005b8181101561051a576104bb606782610be9565b8583815181106104cd576104cd611a20565b602002602001018584815181106104e6576104e6611a20565b60200260200101826001600160a01b03166001600160a01b03168152508281525050508061051390611a4c565b90506104a8565b50509091565b336000908152610135602052604081205460ff166105855760405162461bcd60e51b815260206004820152600560248201527f216175746800000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600061271061059461019a5490565b61059e9085611a65565b6105a89190611a7c565b610133546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106349190611a9e565b90508181101561067a576040517fcf479181000000000000000000000000000000000000000000000000000000008152600481018290526024810183905260440161057c565b61013354610692906001600160a01b03168684610c05565b8161013460008282546106a59190611ab7565b909155506106b09050565b7f2c52407333436f259bf6a809fe1ea51b8fbf1cde1a7d084fe1f1091b6502a204610134546040516106e491815260200190565b60405180910390a1846001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8360405161072791815260200190565b60405180910390a25090505b92915050565b610741610c85565b60ce805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60008190036107ab576040517ff1364a7400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561080e576107fc8383838181106107cb576107cb611a20565b90506020020135610134546040516020016107e891815260200190565b604051602081830303815290604052610cdf565b8061080681611a4c565b9150506107ae565b507fab509f25e6e3409df783403b9a98a6bb73a0daee7d9058482eec8df36bc1691582826101345460405161084593929190611aca565b60405180910390a1471561085d5761085d3347610ea3565b5050565b610869610c85565b6108736000610fbc565b565b61087d610c85565b6108896067838361101b565b505050565b610896610c85565b6001600160a01b0382166108ec5760405162461bcd60e51b815260206004820152601260248201527f696e76616c6964205f6f70657261746f72210000000000000000000000000000604482015260640161057c565b6001600160a01b03821660008181526101356020908152604091829020805460ff19168515159081179091558251938452908301527f18ac1b80d115f1f71f132ed0e5ffe7a01649c5e7a4687b7aa8bdcbde68455939910160405180910390a15050565b600054610100900460ff16158080156109705750600054600160ff909116105b8061098a5750303b15801561098a575060005460ff166001145b6109fc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161057c565b6000805460ff191660011790558015610a1f576000805461ff0019166101001790555b610a2b8585858561103b565b61271061019a8190556040519081527f964914f281ea618d69b9cc26aec36db4040b90f276829ada2d22e206f7ede2659060200160405180910390a18015610aad576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b610abc610c85565b606655565b60ce546001600160a01b03163314610b07576040517f56b82aea00000000000000000000000000000000000000000000000000000000815233600482015260240161057c565b610b48848484848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506110b292505050565b50505050565b610b56610c85565b6001600160a01b038116610bd25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161057c565b610bdb81610fbc565b50565b600061073382611104565b6000808080610bf8868661110f565b9097909650945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261088990849061113a565b6033546001600160a01b031633146108735760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161057c565b610cea60678361121f565b610cf657610cf6611b21565b6000610d0360678461122b565b6066546065546040517feb0af6ba00000000000000000000000000000000000000000000000000000000815292935090916000916001600160a01b03169063eb0af6ba90610d5b908890879089908890600401611b87565b602060405180830381865afa158015610d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9c9190611a9e565b905080471015610de1576040517fe098b7ca0000000000000000000000000000000000000000000000000000000081524760048201526024810182905260440161057c565b6065546040517f74e583fc0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906374e583fc908390610e3290899088908a908990600401611b87565b6000604051808303818588803b158015610e4b57600080fd5b505af1158015610e5f573d6000803e3d6000fd5b5050505050847fc712776e3ba1c0956ddaa7dddccc9d5307821c4f2f2dd03d581164ba6faf5d2285604051610e949190611bc0565b60405180910390a25050505050565b80471015610ef35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161057c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610f40576040519150601f19603f3d011682016040523d82523d6000602084013e610f45565b606091505b50509050806108895760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161057c565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061103184846001600160a01b038516611237565b90505b9392505050565b600054610100900460ff166110a65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b610b4884848484611254565b808060200190518101906110c69190611a9e565b61019a8190556040519081527f964914f281ea618d69b9cc26aec36db4040b90f276829ada2d22e206f7ede2659060200160405180910390a1505050565b600061073382611306565b6000808061111d8585611310565b600081815260029690960160205260409095205494959350505050565b600061118f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661131c9092919063ffffffff16565b80519091501561088957808060200190518101906111ad9190611bd3565b6108895760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161057c565b6000611034838361132b565b60006110348383611337565b6000828152600284016020526040812082905561103184846113a7565b600054610100900460ff166112bf5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6112c983836113b3565b6112d281611459565b5050610133805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03939093169290921790915550565b6000610733825490565b600061103483836114cc565b606061103184846000856114f6565b6000611034838361163e565b60008181526002830160205260408120548015158061135b575061135b848461132b565b6110345760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000604482015260640161057c565b60006110348383611656565b600054610100900460ff1661141e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6114266116a5565b6065805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039390931692909217909155606655565b600054610100900460ff166114c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6107416116a5565b60008260000182815481106114e3576114e3611a20565b9060005260206000200154905092915050565b60608247101561156e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161057c565b6001600160a01b0385163b6115c55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161057c565b600080866001600160a01b031685876040516115e19190611bf0565b60006040518083038185875af1925050503d806000811461161e576040519150601f19603f3d011682016040523d82523d6000602084013e611623565b606091505b5091509150611633828286611719565b979650505050505050565b60008181526001830160205260408120541515611034565b600081815260018301602052604081205461169d57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610733565b506000610733565b600054610100900460ff166117105760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b61087333610fbc565b60608315611728575081611034565b8251156117385782518084602001fd5b8160405162461bcd60e51b815260040161057c9190611bc0565b604080825283519082018190526000906020906060840190828701845b8281101561178b5781518452928401929084019060010161176f565b5050508381038285015284518082528583019183019060005b818110156117c95783516001600160a01b0316835292840192918401916001016117a4565b5090979650505050505050565b80356001600160a01b03811681146117ed57600080fd5b919050565b6000806040838503121561180557600080fd5b61180e836117d6565b946020939093013593505050565b60006020828403121561182e57600080fd5b611034826117d6565b6000806020838503121561184a57600080fd5b823567ffffffffffffffff8082111561186257600080fd5b818501915085601f83011261187657600080fd5b81358181111561188557600080fd5b8660208260051b850101111561189a57600080fd5b60209290920196919550909350505050565b600080604083850312156118bf57600080fd5b823591506118cf602084016117d6565b90509250929050565b8015158114610bdb57600080fd5b600080604083850312156118f957600080fd5b611902836117d6565b91506020830135611912816118d8565b809150509250929050565b6000806000806080858703121561193357600080fd5b61193c856117d6565b935061194a602086016117d6565b92506040850135915061195f606086016117d6565b905092959194509250565b60006020828403121561197c57600080fd5b5035919050565b6000806000806060858703121561199957600080fd5b843593506119a9602086016117d6565b9250604085013567ffffffffffffffff808211156119c657600080fd5b818701915087601f8301126119da57600080fd5b8135818111156119e957600080fd5b8860208285010111156119fb57600080fd5b95989497505060200194505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611a5e57611a5e611a36565b5060010190565b808202811582820484141761073357610733611a36565b600082611a9957634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611ab057600080fd5b5051919050565b8082018082111561073357610733611a36565b6040815282604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841115611b0357600080fd5b8360051b808660608501376020830193909352500160600192915050565b634e487b7160e01b600052600160045260246000fd5b60005b83811015611b52578181015183820152602001611b3a565b50506000910152565b60008151808452611b73816020860160208601611b37565b601f01601f19169290920160200192915050565b8481526001600160a01b0384166020820152608060408201526000611baf6080830185611b5b565b905082606083015295945050505050565b6020815260006110346020830184611b5b565b600060208284031215611be557600080fd5b8151611034816118d8565b60008251611c02818460208701611b37565b919091019291505056fea26469706673582212203efc17fa69bb5e7257222208ae9cf8ef8eabbb50a80eed6e8e504ccf6184aacf64736f6c63430008110033
Deployed Bytecode
0x60806040526004361061016a5760003560e01c8063715018a6116100cb578063b84614a51161007f578063d65b394311610059578063d65b3943146103aa578063dd64e57c146103ca578063f2fde38b146103ea57600080fd5b8063b84614a51461034a578063be2030941461036a578063d45f5e211461038a57600080fd5b80638da5cb5b116100b05780638da5cb5b14610300578063918f86741461031e5780639efc75751461033457600080fd5b8063715018a6146102d8578063799233e4146102ed57600080fd5b80635dbd1688116101225780636349d251116101075780636349d2511461023e578063646fcdd2146102765780636fae3d761461029757600080fd5b80635dbd1688146102095780635edf676c1461022b57600080fd5b806340c10f191161015357806340c10f19146101bc5780635184cc43146101dc57806354f703f8146101f257600080fd5b80632d3802421461016f5780633e39b65014610199575b600080fd5b34801561017b57600080fd5b506101866101345481565b6040519081526020015b60405180910390f35b3480156101a557600080fd5b506101ae61040a565b604051610190929190611752565b3480156101c857600080fd5b506101866101d73660046117f2565b610520565b3480156101e857600080fd5b5061019a54610186565b3480156101fe57600080fd5b5061018661019a5481565b34801561021557600080fd5b5061022961022436600461181c565b610739565b005b610229610239366004611837565b610770565b34801561024a57600080fd5b5060655461025e906001600160a01b031681565b6040516001600160a01b039091168152602001610190565b34801561028257600080fd5b506101335461025e906001600160a01b031681565b3480156102a357600080fd5b506102c86102b236600461181c565b6101356020526000908152604090205460ff1681565b6040519015158152602001610190565b3480156102e457600080fd5b50610229610861565b6102296102fb3660046118ac565b610875565b34801561030c57600080fd5b506033546001600160a01b031661025e565b34801561032a57600080fd5b5061018661271081565b34801561034057600080fd5b5061018660665481565b34801561035657600080fd5b506102296103653660046118e6565b61088e565b34801561037657600080fd5b5061022961038536600461191d565b610950565b34801561039657600080fd5b506102296103a536600461196a565b610ab4565b3480156103b657600080fd5b5060ce5461025e906001600160a01b031681565b3480156103d657600080fd5b506102296103e5366004611983565b610ac1565b3480156103f657600080fd5b5061022961040536600461181c565b610b4e565b60608060006104196067610bde565b90508067ffffffffffffffff81111561043457610434611a0a565b60405190808252806020026020018201604052801561045d578160200160208202803683370190505b5092508067ffffffffffffffff81111561047957610479611a0a565b6040519080825280602002602001820160405280156104a2578160200160208202803683370190505b50915060005b8181101561051a576104bb606782610be9565b8583815181106104cd576104cd611a20565b602002602001018584815181106104e6576104e6611a20565b60200260200101826001600160a01b03166001600160a01b03168152508281525050508061051390611a4c565b90506104a8565b50509091565b336000908152610135602052604081205460ff166105855760405162461bcd60e51b815260206004820152600560248201527f216175746800000000000000000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600061271061059461019a5490565b61059e9085611a65565b6105a89190611a7c565b610133546040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529192506000916001600160a01b03909116906370a0823190602401602060405180830381865afa158015610610573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106349190611a9e565b90508181101561067a576040517fcf479181000000000000000000000000000000000000000000000000000000008152600481018290526024810183905260440161057c565b61013354610692906001600160a01b03168684610c05565b8161013460008282546106a59190611ab7565b909155506106b09050565b7f2c52407333436f259bf6a809fe1ea51b8fbf1cde1a7d084fe1f1091b6502a204610134546040516106e491815260200190565b60405180910390a1846001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8360405161072791815260200190565b60405180910390a25090505b92915050565b610741610c85565b60ce805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60008190036107ab576040517ff1364a7400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8181101561080e576107fc8383838181106107cb576107cb611a20565b90506020020135610134546040516020016107e891815260200190565b604051602081830303815290604052610cdf565b8061080681611a4c565b9150506107ae565b507fab509f25e6e3409df783403b9a98a6bb73a0daee7d9058482eec8df36bc1691582826101345460405161084593929190611aca565b60405180910390a1471561085d5761085d3347610ea3565b5050565b610869610c85565b6108736000610fbc565b565b61087d610c85565b6108896067838361101b565b505050565b610896610c85565b6001600160a01b0382166108ec5760405162461bcd60e51b815260206004820152601260248201527f696e76616c6964205f6f70657261746f72210000000000000000000000000000604482015260640161057c565b6001600160a01b03821660008181526101356020908152604091829020805460ff19168515159081179091558251938452908301527f18ac1b80d115f1f71f132ed0e5ffe7a01649c5e7a4687b7aa8bdcbde68455939910160405180910390a15050565b600054610100900460ff16158080156109705750600054600160ff909116105b8061098a5750303b15801561098a575060005460ff166001145b6109fc5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161057c565b6000805460ff191660011790558015610a1f576000805461ff0019166101001790555b610a2b8585858561103b565b61271061019a8190556040519081527f964914f281ea618d69b9cc26aec36db4040b90f276829ada2d22e206f7ede2659060200160405180910390a18015610aad576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b610abc610c85565b606655565b60ce546001600160a01b03163314610b07576040517f56b82aea00000000000000000000000000000000000000000000000000000000815233600482015260240161057c565b610b48848484848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506110b292505050565b50505050565b610b56610c85565b6001600160a01b038116610bd25760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161057c565b610bdb81610fbc565b50565b600061073382611104565b6000808080610bf8868661110f565b9097909650945050505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905261088990849061113a565b6033546001600160a01b031633146108735760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161057c565b610cea60678361121f565b610cf657610cf6611b21565b6000610d0360678461122b565b6066546065546040517feb0af6ba00000000000000000000000000000000000000000000000000000000815292935090916000916001600160a01b03169063eb0af6ba90610d5b908890879089908890600401611b87565b602060405180830381865afa158015610d78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9c9190611a9e565b905080471015610de1576040517fe098b7ca0000000000000000000000000000000000000000000000000000000081524760048201526024810182905260440161057c565b6065546040517f74e583fc0000000000000000000000000000000000000000000000000000000081526001600160a01b03909116906374e583fc908390610e3290899088908a908990600401611b87565b6000604051808303818588803b158015610e4b57600080fd5b505af1158015610e5f573d6000803e3d6000fd5b5050505050847fc712776e3ba1c0956ddaa7dddccc9d5307821c4f2f2dd03d581164ba6faf5d2285604051610e949190611bc0565b60405180910390a25050505050565b80471015610ef35760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161057c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610f40576040519150601f19603f3d011682016040523d82523d6000602084013e610f45565b606091505b50509050806108895760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161057c565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600061103184846001600160a01b038516611237565b90505b9392505050565b600054610100900460ff166110a65760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b610b4884848484611254565b808060200190518101906110c69190611a9e565b61019a8190556040519081527f964914f281ea618d69b9cc26aec36db4040b90f276829ada2d22e206f7ede2659060200160405180910390a1505050565b600061073382611306565b6000808061111d8585611310565b600081815260029690960160205260409095205494959350505050565b600061118f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661131c9092919063ffffffff16565b80519091501561088957808060200190518101906111ad9190611bd3565b6108895760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161057c565b6000611034838361132b565b60006110348383611337565b6000828152600284016020526040812082905561103184846113a7565b600054610100900460ff166112bf5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6112c983836113b3565b6112d281611459565b5050610133805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03939093169290921790915550565b6000610733825490565b600061103483836114cc565b606061103184846000856114f6565b6000611034838361163e565b60008181526002830160205260408120548015158061135b575061135b848461132b565b6110345760405162461bcd60e51b815260206004820152601e60248201527f456e756d657261626c654d61703a206e6f6e6578697374656e74206b65790000604482015260640161057c565b60006110348383611656565b600054610100900460ff1661141e5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6114266116a5565b6065805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039390931692909217909155606655565b600054610100900460ff166114c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b6107416116a5565b60008260000182815481106114e3576114e3611a20565b9060005260206000200154905092915050565b60608247101561156e5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c0000000000000000000000000000000000000000000000000000606482015260840161057c565b6001600160a01b0385163b6115c55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161057c565b600080866001600160a01b031685876040516115e19190611bf0565b60006040518083038185875af1925050503d806000811461161e576040519150601f19603f3d011682016040523d82523d6000602084013e611623565b606091505b5091509150611633828286611719565b979650505050505050565b60008181526001830160205260408120541515611034565b600081815260018301602052604081205461169d57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610733565b506000610733565b600054610100900460ff166117105760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161057c565b61087333610fbc565b60608315611728575081611034565b8251156117385782518084602001fd5b8160405162461bcd60e51b815260040161057c9190611bc0565b604080825283519082018190526000906020906060840190828701845b8281101561178b5781518452928401929084019060010161176f565b5050508381038285015284518082528583019183019060005b818110156117c95783516001600160a01b0316835292840192918401916001016117a4565b5090979650505050505050565b80356001600160a01b03811681146117ed57600080fd5b919050565b6000806040838503121561180557600080fd5b61180e836117d6565b946020939093013593505050565b60006020828403121561182e57600080fd5b611034826117d6565b6000806020838503121561184a57600080fd5b823567ffffffffffffffff8082111561186257600080fd5b818501915085601f83011261187657600080fd5b81358181111561188557600080fd5b8660208260051b850101111561189a57600080fd5b60209290920196919550909350505050565b600080604083850312156118bf57600080fd5b823591506118cf602084016117d6565b90509250929050565b8015158114610bdb57600080fd5b600080604083850312156118f957600080fd5b611902836117d6565b91506020830135611912816118d8565b809150509250929050565b6000806000806080858703121561193357600080fd5b61193c856117d6565b935061194a602086016117d6565b92506040850135915061195f606086016117d6565b905092959194509250565b60006020828403121561197c57600080fd5b5035919050565b6000806000806060858703121561199957600080fd5b843593506119a9602086016117d6565b9250604085013567ffffffffffffffff808211156119c657600080fd5b818701915087601f8301126119da57600080fd5b8135818111156119e957600080fd5b8860208285010111156119fb57600080fd5b95989497505060200194505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611a5e57611a5e611a36565b5060010190565b808202811582820484141761073357610733611a36565b600082611a9957634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611ab057600080fd5b5051919050565b8082018082111561073357610733611a36565b6040815282604082015260007f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff841115611b0357600080fd5b8360051b808660608501376020830193909352500160600192915050565b634e487b7160e01b600052600160045260246000fd5b60005b83811015611b52578181015183820152602001611b3a565b50506000910152565b60008151808452611b73816020860160208601611b37565b601f01601f19169290920160200192915050565b8481526001600160a01b0384166020820152608060408201526000611baf6080830185611b5b565b905082606083015295945050505050565b6020815260006110346020830184611b5b565b600060208284031215611be557600080fd5b8151611034816118d8565b60008251611c02818460208701611b37565b919091019291505056fea26469706673582212203efc17fa69bb5e7257222208ae9cf8ef8eabbb50a80eed6e8e504ccf6184aacf64736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.277189 | 1,692,130.0207 | $469,039.83 |
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.