Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
190588 | 134 days ago | Contract Creation | 0 S |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xa2A467f3...422ce4621 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
AvoRegistry
Compiler Version
v0.8.18+commit.87f61d96
Optimization Enabled:
Yes with 10000000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity >=0.8.18; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { Address } from "@openzeppelin/contracts/utils/Address.sol"; import { IAvoFactory } from "./interfaces/IAvoFactory.sol"; import { IAvoRegistry, IAvoFeeCollector } from "./interfaces/IAvoRegistry.sol"; // empty interface used for Natspec docs for nice layout in automatically generated docs: // /// @title AvoRegistry v1.0.0 /// @notice Registry for various config data and general actions for Avocado contracts: /// - holds lists of valid versions for Avocado & AvoForwarder /// - handles fees for `castAuthorized()` calls /// /// Upgradeable through AvoRegistryProxy interface AvoRegistry_V1 { } abstract contract AvoRegistryConstants is IAvoRegistry { /// @notice AvoFactory where new versions get registered automatically as default version on `registerAvoVersion()` IAvoFactory public immutable avoFactory; /// @dev maximum fee possible when mode is percentage (mode = 0) uint256 internal constant MAX_PERCENTAGE_FEE = 1e9; // 1_000% (top-up fee can be more than 100%) constructor(IAvoFactory avoFactory_) { avoFactory = avoFactory_; } } abstract contract AvoRegistryVariables is IAvoRegistry, Initializable, OwnableUpgradeable { // @dev variables here start at storage slot 101, before is: // - Initializable with storage slot 0: // uint8 private _initialized; // bool private _initializing; // - OwnableUpgradeable with slots 1 to 100: // uint256[50] private __gap; (from ContextUpgradeable, slot 1 until slot 50) // address private _owner; (at slot 51) // uint256[49] private __gap; (slot 52 until slot 100) // ---------------- slot 101 ----------------- /// @notice fee config for `calcFee()`. Configurable by owner. FeeConfig public feeConfig; // ---------------- slot 102 ----------------- /// @notice mapping to store allowed Avocado versions. Modifiable by owner. mapping(address => bool) public avoVersions; // ---------------- slot 103 ----------------- /// @notice mapping to store allowed AvoForwarder versions. Modifiable by owner. mapping(address => bool) public avoForwarderVersions; } abstract contract AvoRegistryErrors { /// @notice thrown for `requireVersion()` methods error AvoRegistry__InvalidVersion(); /// @notice thrown when a requested fee mode is not implemented error AvoRegistry__FeeModeNotImplemented(uint8 mode); /// @notice thrown when a method is called with invalid params, e.g. the zero address error AvoRegistry__InvalidParams(); /// @notice thrown when an unsupported method is called (e.g. renounceOwnership) error AvoRegistry__Unsupported(); } abstract contract AvoRegistryEvents is IAvoRegistry { /// @notice emitted when the status for a certain AvoMultsig version is updated event SetAvoVersion(address indexed avoVersion, bool indexed allowed, bool indexed setDefault); /// @notice emitted when the status for a certain AvoForwarder version is updated event SetAvoForwarderVersion(address indexed avoForwarderVersion, bool indexed allowed); /// @notice emitted when the fee config is updated event FeeConfigUpdated(address indexed feeCollector, uint8 indexed mode, uint88 indexed fee); } abstract contract AvoRegistryCore is AvoRegistryConstants, AvoRegistryVariables, AvoRegistryErrors, AvoRegistryEvents { /***********************************| | MODIFIERS | |__________________________________*/ /// @dev checks if an address is not the zero address modifier validAddress(address _address) { if (_address == address(0)) { revert AvoRegistry__InvalidParams(); } _; } modifier isContract(address _address) { if (!Address.isContract(_address)) { revert AvoRegistry__InvalidParams(); } _; } /***********************************| | CONSTRUCTOR / INITIALIZERS | |__________________________________*/ constructor(IAvoFactory avoFactory_) validAddress(address(avoFactory_)) AvoRegistryConstants(avoFactory_) { // ensure logic contract initializer is not abused by disabling initializing // see https://forum.openzeppelin.com/t/security-advisory-initialize-uups-implementation-contracts/15301 // and https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract _disableInitializers(); } } abstract contract AvoFeeCollector is AvoRegistryCore { /// @inheritdoc IAvoFeeCollector function calcFee(uint256 gasUsed_) public view returns (uint256 feeAmount_, address payable feeCollector_) { FeeConfig memory feeConfig_ = feeConfig; if (feeConfig_.fee > 0) { if (feeConfig_.mode == 0) { // percentage of `gasUsed_` fee amount mode if (gasUsed_ == 0) { revert AvoRegistry__InvalidParams(); } // fee amount = gasUsed * gasPrice * fee percentage. (tx.gasprice is in wei) feeAmount_ = (gasUsed_ * tx.gasprice * feeConfig_.fee) / 1e8; // 1e8 = 100% } else if (feeConfig_.mode == 1) { // absolute fee amount mode feeAmount_ = feeConfig_.fee; } else { // theoretically not reachable because of check in `updateFeeConfig` but doesn't hurt to have this here revert AvoRegistry__FeeModeNotImplemented(feeConfig_.mode); } } return (feeAmount_, feeConfig_.feeCollector); } /***********************************| | ONLY OWNER | |__________________________________*/ /// @notice sets `feeConfig_` as the new fee config in storage. Only callable by owner. function updateFeeConfig(FeeConfig calldata feeConfig_) external onlyOwner validAddress(feeConfig_.feeCollector) { if (feeConfig_.mode > 1) { revert AvoRegistry__FeeModeNotImplemented(feeConfig_.mode); } if (feeConfig_.mode == 0 && feeConfig_.fee > MAX_PERCENTAGE_FEE) { // in percentage mode, fee can not be more than MAX_PERCENTAGE_FEE revert AvoRegistry__InvalidParams(); } feeConfig = feeConfig_; emit FeeConfigUpdated(feeConfig_.feeCollector, feeConfig_.mode, feeConfig_.fee); } } contract AvoRegistry is AvoRegistryCore, AvoFeeCollector { /***********************************| | CONSTRUCTOR / INITIALIZERS | |__________________________________*/ constructor(IAvoFactory avoFactory_) AvoRegistryCore(avoFactory_) {} /// @notice initializes the contract with `owner_` as owner function initialize(address owner_) public initializer validAddress(owner_) { _transferOwnership(owner_); } /***********************************| | PUBLIC API | |__________________________________*/ /// @inheritdoc IAvoRegistry function requireValidAvoVersion(address avoVersion_) external view { if (!avoVersions[avoVersion_]) { revert AvoRegistry__InvalidVersion(); } } /// @inheritdoc IAvoRegistry function requireValidAvoForwarderVersion(address avoForwarderVersion_) external view { if (!avoForwarderVersions[avoForwarderVersion_]) { revert AvoRegistry__InvalidVersion(); } } /***********************************| | ONLY OWNER | |__________________________________*/ /// @notice sets the status for a certain address as allowed AvoForwarder version. /// Only callable by owner. /// @param avoForwarder_ the address of the contract to treat as AvoForwarder version /// @param allowed_ flag to set this address as valid version (true) or not (false) function setAvoForwarderVersion( address avoForwarder_, bool allowed_ ) external onlyOwner validAddress(avoForwarder_) isContract(avoForwarder_) { avoForwarderVersions[avoForwarder_] = allowed_; emit SetAvoForwarderVersion(avoForwarder_, allowed_); } /// @notice sets the status for a certain address as allowed / default Avocado version. /// Only callable by owner. /// @param avoVersion_ the address of the contract to treat as Avocado version /// @param allowed_ flag to set this address as valid version (true) or not (false) /// @param setDefault_ flag to indicate whether this version should automatically be set as new /// default version for new deployments at the linked `avoFactory` function setAvoVersion( address avoVersion_, bool allowed_, bool setDefault_ ) external onlyOwner validAddress(avoVersion_) isContract(avoVersion_) { if (!allowed_ && setDefault_) { // can't be not allowed but supposed to be set as default revert AvoRegistry__InvalidParams(); } avoVersions[avoVersion_] = allowed_; if (setDefault_) { // register the new version as default version at the linked AvoFactory avoFactory.setAvoImpl(avoVersion_); } emit SetAvoVersion(avoVersion_, allowed_, setDefault_); } /// @notice override renounce ownership as it could leave the contract in an unwanted state if called by mistake. function renounceOwnership() public view override onlyOwner { revert AvoRegistry__Unsupported(); } }
// 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.8.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. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.18; import { IAvoRegistry } from "./IAvoRegistry.sol"; interface IAvoFactory { /// @notice returns AvoRegistry (proxy) address function avoRegistry() external view returns (IAvoRegistry); /// @notice returns Avocado logic contract address that new Avocado deployments point to function avoImpl() external view returns (address); /// @notice Checks if a certain address is an Avocado smart wallet. /// Only works for already deployed wallets. /// @param avoSmartWallet_ address to check /// @return true if address is an Avocado function isAvocado(address avoSmartWallet_) external view returns (bool); /// @notice Computes the deterministic Avocado address for `owner_` based on Create2 /// @param owner_ Avocado owner /// @param index_ index number of Avocado for `owner_` EOA /// @return computedAddress_ computed address for the Avocado contract function computeAvocado(address owner_, uint32 index_) external view returns (address computedAddress_); /// @notice Deploys an Avocado for a certain `owner_` deterministcally using Create2. /// Does not check if contract at address already exists (AvoForwarder does that) /// @param owner_ Avocado owner /// @param index_ index number of Avocado for `owner_` EOA /// @return deployed address for the Avocado contract function deploy(address owner_, uint32 index_) external returns (address); /// @notice Deploys an Avocado with non-default version for an `owner_` /// deterministcally using Create2. /// Does not check if contract at address already exists (AvoForwarder does that) /// @param owner_ Avocado owner /// @param index_ index number of Avocado for `owner_` EOA /// @param avoVersion_ Version of Avocado logic contract to deploy /// @return deployed address for the Avocado contract function deployWithVersion(address owner_, uint32 index_, address avoVersion_) external returns (address); /// @notice registry can update the current Avocado implementation contract set as default /// `_avoImpl` logic contract address for new deployments /// @param avoImpl_ the new avoImpl address function setAvoImpl(address avoImpl_) external; /// @notice returns the byteCode for the Avocado contract used for Create2 address computation function avocadoBytecode() external view returns (bytes32); }
// SPDX-License-Identifier: MIT pragma solidity >=0.8.18; interface IAvoFeeCollector { /// @notice fee config params used to determine the fee for Avocado smart wallet `castAuthorized()` calls struct FeeConfig { /// @param feeCollector address that the fee should be paid to address payable feeCollector; /// @param mode current fee mode: 0 = percentage fee (gas cost markup); 1 = static fee (better for L2) uint8 mode; /// @param fee current fee amount: /// - for mode percentage: fee in 1e6 percentage (1e8 = 100%, 1e6 = 1%) /// - for static mode: absolute amount in native gas token to charge /// (max value 30_9485_009,821345068724781055 in 1e18) uint88 fee; } /// @notice calculates the `feeAmount_` for an Avocado (`msg.sender`) transaction `gasUsed_` based on /// fee configuration present on the contract /// @param gasUsed_ amount of gas used, required if mode is percentage. not used if mode is static fee. /// @return feeAmount_ calculate fee amount to be paid /// @return feeCollector_ address to send the fee to function calcFee(uint256 gasUsed_) external view returns (uint256 feeAmount_, address payable feeCollector_); } interface IAvoRegistry is IAvoFeeCollector { /// @notice checks if an address is listed as allowed AvoForwarder version, reverts if not. /// @param avoForwarderVersion_ address of the AvoForwarder logic contract to check function requireValidAvoForwarderVersion(address avoForwarderVersion_) external view; /// @notice checks if an address is listed as allowed Avocado version, reverts if not. /// @param avoVersion_ address of the Avocado logic contract to check function requireValidAvoVersion(address avoVersion_) external view; }
{ "optimizer": { "enabled": true, "runs": 10000000 }, "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IAvoFactory","name":"avoFactory_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint8","name":"mode","type":"uint8"}],"name":"AvoRegistry__FeeModeNotImplemented","type":"error"},{"inputs":[],"name":"AvoRegistry__InvalidParams","type":"error"},{"inputs":[],"name":"AvoRegistry__InvalidVersion","type":"error"},{"inputs":[],"name":"AvoRegistry__Unsupported","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"feeCollector","type":"address"},{"indexed":true,"internalType":"uint8","name":"mode","type":"uint8"},{"indexed":true,"internalType":"uint88","name":"fee","type":"uint88"}],"name":"FeeConfigUpdated","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":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"avoForwarderVersion","type":"address"},{"indexed":true,"internalType":"bool","name":"allowed","type":"bool"}],"name":"SetAvoForwarderVersion","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"avoVersion","type":"address"},{"indexed":true,"internalType":"bool","name":"allowed","type":"bool"},{"indexed":true,"internalType":"bool","name":"setDefault","type":"bool"}],"name":"SetAvoVersion","type":"event"},{"inputs":[],"name":"avoFactory","outputs":[{"internalType":"contract IAvoFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"avoForwarderVersions","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"avoVersions","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasUsed_","type":"uint256"}],"name":"calcFee","outputs":[{"internalType":"uint256","name":"feeAmount_","type":"uint256"},{"internalType":"address payable","name":"feeCollector_","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeConfig","outputs":[{"internalType":"address payable","name":"feeCollector","type":"address"},{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint88","name":"fee","type":"uint88"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"avoForwarderVersion_","type":"address"}],"name":"requireValidAvoForwarderVersion","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"avoVersion_","type":"address"}],"name":"requireValidAvoVersion","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"avoForwarder_","type":"address"},{"internalType":"bool","name":"allowed_","type":"bool"}],"name":"setAvoForwarderVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"avoVersion_","type":"address"},{"internalType":"bool","name":"allowed_","type":"bool"},{"internalType":"bool","name":"setDefault_","type":"bool"}],"name":"setAvoVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"feeCollector","type":"address"},{"internalType":"uint8","name":"mode","type":"uint8"},{"internalType":"uint88","name":"fee","type":"uint88"}],"internalType":"struct IAvoFeeCollector.FeeConfig","name":"feeConfig_","type":"tuple"}],"name":"updateFeeConfig","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100e95760003560e01c80638da5cb5b1161008c578063b0c5ea8811610066578063b0c5ea88146102b0578063c4d66de8146102d7578063c5211e67146102ea578063f2fde38b1461030d57600080fd5b80638da5cb5b1461022b5780638f4cd1481461026a5780639616b0581461027d57600080fd5b80635721aa40116100c85780635721aa40146101c057806358330461146101d3578063715018a6146101e657806375dc7d8c146101ee57600080fd5b8062fe90e3146100ee57806303d50d34146101035780631e5eb1d014610116575b600080fd5b6101016100fc366004610e66565b610320565b005b610101610111366004610e66565b610382565b60655461017a9073ffffffffffffffffffffffffffffffffffffffff81169074010000000000000000000000000000000000000000810460ff1690750100000000000000000000000000000000000000000090046affffffffffffffffffffff1683565b6040805173ffffffffffffffffffffffffffffffffffffffff909416845260ff90921660208401526affffffffffffffffffffff16908201526060015b60405180910390f35b6101016101ce366004610e8a565b6103e1565b6101016101e1366004610eb7565b6105b4565b6101016106da565b6102016101fc366004610eec565b610714565b6040805192835273ffffffffffffffffffffffffffffffffffffffff9091166020830152016101b7565b60335473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101b7565b610101610278366004610f05565b610885565b6102a061028b366004610e66565b60666020526000908152604090205460ff1681565b60405190151581526020016101b7565b6102457f00000000000000000000000009389f927ae43f93958a4ebf2bbb24b9fe88f6c581565b6101016102e5366004610e66565b610ab3565b6102a06102f8366004610e66565b60676020526000908152604090205460ff1681565b61010161031b366004610e66565b610c96565b73ffffffffffffffffffffffffffffffffffffffff811660009081526066602052604090205460ff1661037f576040517fa8156e3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b73ffffffffffffffffffffffffffffffffffffffff811660009081526067602052604090205460ff1661037f576040517fa8156e3400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6103e9610d4a565b6103f66020820182610e66565b73ffffffffffffffffffffffffffffffffffffffff8116610443576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016104556040840160208501610f59565b60ff1611156104ab5761046e6040830160208401610f59565b6040517fbb98058200000000000000000000000000000000000000000000000000000000815260ff90911660048201526024015b60405180910390fd5b6104bb6040830160208401610f59565b60ff161580156104ea5750633b9aca006104db6060840160408501610f8f565b6affffffffffffffffffffff16115b15610521576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81606561052e8282610fac565b5061054190506060830160408401610f8f565b6affffffffffffffffffffff1661055e6040840160208501610f59565b60ff1661056e6020850185610e66565b73ffffffffffffffffffffffffffffffffffffffff167ffb14f30de2feb6d7f2c3720d4bdfd2dd2485625b36e949c747693350af19294a60405160405180910390a45050565b6105bc610d4a565b8173ffffffffffffffffffffffffffffffffffffffff811661060a576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff81163b610659576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841660008181526067602052604080822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001687151590811790915590519092917f5f4cc2a16c6cf2b71ed34daeda95a81ad02912efeec06f8a84b217638ee4bb4891a350505050565b6106e2610d4a565b6040517f04e2c0b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040805160608101825260655473ffffffffffffffffffffffffffffffffffffffff8116825274010000000000000000000000000000000000000000810460ff166020830152750100000000000000000000000000000000000000000090046affffffffffffffffffffff169181018290526000918291901561087c57806020015160ff1660000361081757836000036107da576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408101516305f5e100906affffffffffffffffffffff166107fc3a8761106f565b610806919061106f565b61081091906110b3565b925061087c565b806020015160ff1660010361083f5780604001516affffffffffffffffffffff16925061087c565b60208101516040517fbb98058200000000000000000000000000000000000000000000000000000000815260ff90911660048201526024016104a2565b51919391925050565b61088d610d4a565b8273ffffffffffffffffffffffffffffffffffffffff81166108db576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff81163b61092a576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b831580156109355750825b1561096c576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8516600090815260666020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168515151790558215610a63576040517f665e305800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff86811660048301527f00000000000000000000000009389f927ae43f93958a4ebf2bbb24b9fe88f6c5169063665e305890602401600060405180830381600087803b158015610a4a57600080fd5b505af1158015610a5e573d6000803e3d6000fd5b505050505b8215158415158673ffffffffffffffffffffffffffffffffffffffff167f2f5f958ca56f2e56287e16ec8b40c47a1148b2386b1b90dc2c2fcb280d3d991260405160405180910390a45050505050565b600054610100900460ff1615808015610ad35750600054600160ff909116105b80610aed5750303b158015610aed575060005460ff166001145b610b79576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084016104a2565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790558015610bd757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b8173ffffffffffffffffffffffffffffffffffffffff8116610c25576040517f22f33f7900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c2e83610dcd565b508015610c9257600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b610c9e610d4a565b73ffffffffffffffffffffffffffffffffffffffff8116610d41576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104a2565b61037f81610dcd565b60335473ffffffffffffffffffffffffffffffffffffffff163314610dcb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a2565b565b6033805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b73ffffffffffffffffffffffffffffffffffffffff8116811461037f57600080fd5b600060208284031215610e7857600080fd5b8135610e8381610e44565b9392505050565b600060608284031215610e9c57600080fd5b50919050565b80358015158114610eb257600080fd5b919050565b60008060408385031215610eca57600080fd5b8235610ed581610e44565b9150610ee360208401610ea2565b90509250929050565b600060208284031215610efe57600080fd5b5035919050565b600080600060608486031215610f1a57600080fd5b8335610f2581610e44565b9250610f3360208501610ea2565b9150610f4160408501610ea2565b90509250925092565b60ff8116811461037f57600080fd5b600060208284031215610f6b57600080fd5b8135610e8381610f4a565b6affffffffffffffffffffff8116811461037f57600080fd5b600060208284031215610fa157600080fd5b8135610e8381610f76565b8135610fb781610e44565b73ffffffffffffffffffffffffffffffffffffffff811690508154817fffffffffffffffffffffffff00000000000000000000000000000000000000008216178355602084013561100781610f4a565b74ff00000000000000000000000000000000000000008160a01b1690507fffffffffffffffffffffff0000000000000000000000000000000000000000008184828516171785556040860135925061105e83610f76565b921760a89190911b90911617905550565b80820281158282048414176110ad577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b92915050565b6000826110e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50049056fea264697066735822122031922501e969fd6082e6125f5e869a673d8066c98de061138d7d1e94bb0c5bc964736f6c63430008120033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.