Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
VaultWrapper
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {OwnableUpgradeable} from "@openzeppelin-upgradeable/contracts/access/OwnableUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol"; import {SafeTransferLib, ERC20} from "@solmate/utils/SafeTransferLib.sol"; import {IFundsFacet} from "src/interfaces/IFundsFacet.sol"; import {ISwapper, SwapArgs} from "src/interfaces/ISwapper.sol"; import {IWETH} from "src/interfaces/external/weth/IWETH.sol"; import {LibErrors} from "src/libraries/LibErrors.sol"; /** * @title VaultWrapper * @dev Contract that wraps ETH and interacts with the FundsFacet for deposits and swaps. */ contract VaultWrapper is OwnableUpgradeable, UUPSUpgradeable { using SafeTransferLib for ERC20; IWETH public immutable weth; ISwapper public immutable swapper; /// @custom:oz-upgrades-unsafe-allow constructor constructor(IWETH weth_, ISwapper swapper_) { weth = weth_; swapper = swapper_; _disableInitializers(); } /** * @dev Initializes the contract with the given owner. * @param owner The address of the owner. */ function initialize(address owner) external initializer { __Ownable_init(owner); } /** * @dev Wraps ETH and deposits it into the specified vault. * @param yelayLiteVault The address of the vault. * @param projectId The ID of the project. * @return shares The amount of shares received. */ function wrapEthAndDeposit(address yelayLiteVault, uint256 projectId) external payable returns (uint256 shares) { require(msg.value > 0, LibErrors.NoEth()); weth.deposit{value: msg.value}(); ERC20(address(weth)).safeApprove(yelayLiteVault, msg.value); return IFundsFacet(yelayLiteVault).deposit(msg.value, projectId, msg.sender); } /** * @dev Swaps tokens and deposits the resulting assets into the specified vault. * @param yelayLiteVault The address of the vault. * @param projectId The ID of the project. * @param swapArgs The swap arguments. * @param amount The amount of tokens to swap. * @return shares The amount of shares received. */ function swapAndDeposit(address yelayLiteVault, uint256 projectId, SwapArgs calldata swapArgs, uint256 amount) external payable returns (uint256 shares) { if (msg.value > 0) { require(swapArgs.tokenIn == address(weth), LibErrors.NotWeth()); weth.deposit{value: msg.value}(); ERC20(address(weth)).safeTransfer(address(swapper), msg.value); } else { ERC20(swapArgs.tokenIn).safeTransferFrom(msg.sender, address(swapper), amount); } SwapArgs[] memory swapperArgs = new SwapArgs[](1); swapperArgs[0] = swapArgs; address underlyingAsset = IFundsFacet(yelayLiteVault).underlyingAsset(); uint256 assets = swapper.swap(swapperArgs, underlyingAsset); ERC20(underlyingAsset).safeApprove(yelayLiteVault, assets); shares = IFundsFacet(yelayLiteVault).deposit(assets, projectId, msg.sender); uint256 returnBalance = ERC20(swapArgs.tokenIn).balanceOf(address(this)); if (returnBalance > 0) { if (msg.value > 0) { weth.withdraw(returnBalance); payable(msg.sender).transfer(returnBalance); } else { ERC20(swapArgs.tokenIn).safeTransfer(msg.sender, returnBalance); } } } /** * @dev Authorizes the upgrade of the contract. * @param newImplementation The address of the new implementation. */ function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} /** * @dev Fallback function to receive ETH. */ receive() external payable {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol"; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { /// @custom:storage-location erc7201:openzeppelin.storage.Ownable struct OwnableStorage { address _owner; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300; function _getOwnableStorage() private pure returns (OwnableStorage storage $) { assembly { $.slot := OwnableStorageLocation } } /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ function __Ownable_init(address initialOwner) internal onlyInitializing { __Ownable_init_unchained(initialOwner); } function __Ownable_init_unchained(address initialOwner) internal onlyInitializing { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { OwnableStorage storage $ = _getOwnableStorage(); return $._owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { OwnableStorage storage $ = _getOwnableStorage(); address oldOwner = $._owner; $._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC-1967 compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC-1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol) pragma solidity ^0.8.20; /** * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC. */ interface IERC1967 { /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.21; import {IBeacon} from "../beacon/IBeacon.sol"; import {IERC1967} from "../../interfaces/IERC1967.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This library provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots. */ library ERC1967Utils { /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit IERC1967.Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the ERC-1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit IERC1967.AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the ERC-1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit IERC1967.BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[ERC]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; /// @notice Modern and gas efficient ERC20 + EIP-2612 implementation. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol) /// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol) /// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it. abstract contract ERC20 { /*////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event Transfer(address indexed from, address indexed to, uint256 amount); event Approval(address indexed owner, address indexed spender, uint256 amount); /*////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ string public name; string public symbol; uint8 public immutable decimals; /*////////////////////////////////////////////////////////////// ERC20 STORAGE //////////////////////////////////////////////////////////////*/ uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; /*////////////////////////////////////////////////////////////// EIP-2612 STORAGE //////////////////////////////////////////////////////////////*/ uint256 internal immutable INITIAL_CHAIN_ID; bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR; mapping(address => uint256) public nonces; /*////////////////////////////////////////////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, uint8 _decimals ) { name = _name; symbol = _symbol; decimals = _decimals; INITIAL_CHAIN_ID = block.chainid; INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator(); } /*////////////////////////////////////////////////////////////// ERC20 LOGIC //////////////////////////////////////////////////////////////*/ function approve(address spender, uint256 amount) public virtual returns (bool) { allowance[msg.sender][spender] = amount; emit Approval(msg.sender, spender, amount); return true; } function transfer(address to, uint256 amount) public virtual returns (bool) { balanceOf[msg.sender] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(msg.sender, to, amount); return true; } function transferFrom( address from, address to, uint256 amount ) public virtual returns (bool) { uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals. if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount; balanceOf[from] -= amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(from, to, amount); return true; } /*////////////////////////////////////////////////////////////// EIP-2612 LOGIC //////////////////////////////////////////////////////////////*/ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED"); // Unchecked because the only math done is incrementing // the owner's nonce which cannot realistically overflow. unchecked { address recoveredAddress = ecrecover( keccak256( abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR(), keccak256( abi.encode( keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ), owner, spender, value, nonces[owner]++, deadline ) ) ) ), v, r, s ); require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER"); allowance[recoveredAddress][spender] = value; } emit Approval(owner, spender, value); } function DOMAIN_SEPARATOR() public view virtual returns (bytes32) { return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator(); } function computeDomainSeparator() internal view virtual returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256("1"), block.chainid, address(this) ) ); } /*////////////////////////////////////////////////////////////// INTERNAL MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint(address to, uint256 amount) internal virtual { totalSupply += amount; // Cannot overflow because the sum of all user // balances can't exceed the max uint256 value. unchecked { balanceOf[to] += amount; } emit Transfer(address(0), to, amount); } function _burn(address from, uint256 amount) internal virtual { balanceOf[from] -= amount; // Cannot underflow because a user's balance // will never be larger than the total supply. unchecked { totalSupply -= amount; } emit Transfer(from, address(0), amount); } }
// SPDX-License-Identifier: AGPL-3.0-only pragma solidity >=0.8.0; import {ERC20} from "../tokens/ERC20.sol"; /// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values. /// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol) /// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer. library SafeTransferLib { /*////////////////////////////////////////////////////////////// ETH OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferETH(address to, uint256 amount) internal { bool success; /// @solidity memory-safe-assembly assembly { // Transfer the ETH and store if it succeeded or not. success := call(gas(), to, amount, 0, 0, 0, 0) } require(success, "ETH_TRANSFER_FAILED"); } /*////////////////////////////////////////////////////////////// ERC20 OPERATIONS //////////////////////////////////////////////////////////////*/ function safeTransferFrom( ERC20 token, address from, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument. mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. success := call(gas(), token, 0, freeMemoryPointer, 100, 0, 32) // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data and token has code. if and(iszero(and(eq(mload(0), 1), gt(returndatasize(), 31))), success) { success := iszero(or(iszero(extcodesize(token)), returndatasize())) } } require(success, "TRANSFER_FROM_FAILED"); } function safeTransfer( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. success := call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data and token has code. if and(iszero(and(eq(mload(0), 1), gt(returndatasize(), 31))), success) { success := iszero(or(iszero(extcodesize(token)), returndatasize())) } } require(success, "TRANSFER_FAILED"); } function safeApprove( ERC20 token, address to, uint256 amount ) internal { bool success; /// @solidity memory-safe-assembly assembly { // Get a pointer to some free memory. let freeMemoryPointer := mload(0x40) // Write the abi-encoded calldata into memory, beginning with the function selector. mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000) mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument. mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type. // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2. // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space. success := call(gas(), token, 0, freeMemoryPointer, 68, 0, 32) // Set success to whether the call reverted, if not we check it either // returned exactly 1 (can't just be non-zero data), or had no return data and token has code. if and(iszero(and(eq(mload(0), 1), gt(returndatasize(), 31))), success) { success := iszero(or(iszero(extcodesize(token)), returndatasize())) } } require(success, "APPROVE_FAILED"); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; interface IWETH { function deposit() external payable; function withdraw(uint256 wad) external; function transfer(address dst, uint256 wad) external returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import {IERC1155MetadataURI} from "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol"; import {Reward} from "./IStrategyBase.sol"; import {SwapArgs} from "./ISwapper.sol"; struct StrategyArgs { uint256 index; uint256 amount; } interface IFundsFacet is IERC1155, IERC1155MetadataURI { /** * @dev Returns the total supply of tokens. * @return The total supply of tokens. */ function totalSupply() external view returns (uint256); /** * @dev Returns the total supply of tokens for a given ID. * @param id The token ID. * @return The total supply of tokens for the given ID. */ function totalSupply(uint256 id) external view returns (uint256); /** * @dev Returns the last total assets value. * @return The last total assets value. */ function lastTotalAssets() external view returns (uint256); /** * @dev Returns the timestamp of the last total assets update. * @return The timestamp of the last total assets update. */ function lastTotalAssetsTimestamp() external view returns (uint64); /** * @dev Returns the interval for updating the last total assets. * @return The interval for updating the last total assets. */ function lastTotalAssetsUpdateInterval() external view returns (uint64); /** * @dev Sets the interval for updating the last total assets. * @dev Callable by FUNDS_OPERATOR. * @param interval The new interval. */ function setLastTotalAssetsUpdateInterval(uint64 interval) external; /** * @dev Returns the underlying balance of the contract. * @return The underlying balance. */ function underlyingBalance() external view returns (uint256); /** * @dev Returns the address of the underlying asset. * @return The address of the underlying asset. */ function underlyingAsset() external view returns (address); /** * @dev Returns the address of the yield extractor. * @return The address of the yield extractor. */ function yieldExtractor() external view returns (address); /** * @dev Returns the address of the swapper. * @return The address of the swapper. */ function swapper() external view returns (address); /** * @dev Returns the total assets managed by the contract. * @return assets The total assets managed by the contract. */ function totalAssets() external view returns (uint256 assets); /** * @dev Returns the assets managed by a specific strategy. * @param index The index of the strategy. * @return The assets managed by the strategy. */ function strategyAssets(uint256 index) external view returns (uint256); /** * @dev Returns the rewards for a specific strategy. * @param index The index of the strategy. * @return rewards The rewards for the strategy. */ function strategyRewards(uint256 index) external view returns (Reward[] memory rewards); /** * @dev Deposits assets into the contract. * @param assets The amount of assets to deposit. * @param projectId The project ID. * @param receiver The address of the receiver. * @return shares The amount of shares minted. */ function deposit(uint256 assets, uint256 projectId, address receiver) external returns (uint256 shares); /** * @dev Redeems shares from the contract. * @param shares The amount of shares to redeem. * @param projectId The project ID. * @param receiver The address of the receiver. * @return assets The amount of assets redeemed. */ function redeem(uint256 shares, uint256 projectId, address receiver) external returns (uint256 assets); /** * @dev Migrates a position from one project to another. * @param fromProjectId The ID of the project to migrate from. * @param toProjectId The ID of the project to migrate to. * @param amount The amount to migrate. */ function migratePosition(uint256 fromProjectId, uint256 toProjectId, uint256 amount) external; /** * @dev Deposits assets into a strategy. * @dev Callable by FUNDS_OPERATOR. * @param strategyArgs The strategy arguments. */ function managedDeposit(StrategyArgs calldata strategyArgs) external; /** * @dev Withdraws assets from a strategy. * @dev Callable by FUNDS_OPERATOR. * @param strategyArgs The strategy arguments. */ function managedWithdraw(StrategyArgs calldata strategyArgs) external; /** * @dev Reallocates assets between strategies. * @dev Callable by FUNDS_OPERATOR. * @param withdrawals The strategy arguments for withdrawals. * @param deposits The strategy arguments for deposits. */ function reallocate(StrategyArgs[] calldata withdrawals, StrategyArgs[] calldata deposits) external; /** * @dev Compounds rewards by swapping them for the underlying asset. * @dev Callable by FUNDS_OPERATOR. * @param swapArgs The swap arguments. * @return compounded The amount compounded. */ function swapRewards(SwapArgs[] memory swapArgs) external returns (uint256 compounded); /** * @dev Accrues fees. * @dev Callable by FUNDS_OPERATOR. */ function accrueFee() external; /** * @dev Claims rewards from a strategy. * @dev Callable by FUNDS_OPERATOR. * @param index The index of the strategy. */ function claimStrategyRewards(uint256 index) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; struct Reward { address token; uint256 amount; } interface IStrategyBase { /** * @dev Returns the address of the protocol. * @return The address of the protocol. */ function protocol() external returns (address); /** * @dev Deposits the specified amount into the strategy. * @param amount The amount to deposit. * @param supplement Additional data required for the deposit. */ function deposit(uint256 amount, bytes calldata supplement) external; /** * @dev Withdraws the specified amount from the strategy. * @param amount The amount to withdraw. * @param supplement Additional data required for the withdrawal. * @return withdrawn The actual amount withdrawn. */ function withdraw(uint256 amount, bytes calldata supplement) external returns (uint256 withdrawn); /** * @dev Withdraws all funds from strategy. * @param supplement Additional data required for the withdrawal. * @return withdrawn The actual amount withdrawn. */ function withdrawAll(bytes calldata supplement) external returns (uint256 withdrawn); /** * @dev Returns the asset balance of the strategy for the specified vault. * @param yelayLiteVault The address of the vault. * @param supplement Additional data required for the balance calculation. * @return The asset balance of the strategy. */ function assetBalance(address yelayLiteVault, bytes calldata supplement) external view returns (uint256); /** * @dev Called when the strategy is added. * @param supplement Additional data required for the addition. */ function onAdd(bytes calldata supplement) external; /** * @dev Called when the strategy is removed. * @param supplement Additional data required for the removal. */ function onRemove(bytes calldata supplement) external; /** * @dev Returns the rewards available for the specified vault. * @param yelayLiteVault The address of the vault. * @param supplement Additional data required for the rewards calculation. * @return rewards The rewards available for the vault. */ function viewRewards(address yelayLiteVault, bytes calldata supplement) external view returns (Reward[] memory rewards); /** * @dev Claims the rewards for the strategy. * @param supplement Additional data required for claiming the rewards. */ function claimRewards(bytes calldata supplement) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; struct SwapArgs { address tokenIn; address swapTarget; bytes swapCallData; } struct ExchangeArgs { address exchange; bool allowed; } interface ISwapper { /** * @notice Swaps tokens according to the provided swap arguments. * @param swapArgs The swap arguments. * @param tokenOut The token to be received. * @return tokenOutAmount The amount of tokenOut received. */ function swap(SwapArgs[] memory swapArgs, address tokenOut) external returns (uint256 tokenOutAmount); /** * @notice Updates the exchange allowlist. * @param exchangeArgs The exchange arguments. */ function updateExchangeAllowlist(ExchangeArgs[] calldata exchangeArgs) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.28; library LibErrors { // ===================== OwnerFacet ================================ /** * @dev The caller account is not authorized to perform an operation. * @param account The address of the unauthorized account. */ error OwnableUnauthorizedAccount(address account); /** * @dev The function selector is invalid. * @param selector The invalid function selector. */ error InvalidSelector(bytes4 selector); // ===================== ClientsFacet ================================ /** * @dev The owner address is already used by some client. */ error ClientOwnerReserved(); /** * @dev The caller is not the client owner. */ error NotClientOwner(); /** * @dev The project ID is out of bounds. */ error OutOfBoundProjectId(); /** * @dev The project is already active. */ error ProjectActive(); /** * @dev The client name is empty. */ error ClientNameEmpty(); /** * @dev The client name is empty. */ error ReservedProjectsIsZero(); /** * @dev The client name is already taken. */ error ClientNameTaken(); // ===================== FundsFacet ================================ /** * @dev The project is inactive. */ error ProjectInactive(); /** * @dev The function can only be called in a view context. */ error OnlyView(); /** * @dev Compounding the underlying asset is forbidden. */ error CompoundUnderlyingForbidden(); /** * @dev Position migration is forbidden. */ error PositionMigrationForbidden(); /** * @dev There is not enough underlying assets in YelayLiteVault to cover redeem. */ error NotEnoughInternalFunds(); /** * @dev Redeem doesn't pass minimum asset amount */ error MinRedeem(); // ===================== SwapWrapper ================================ /** * @dev The token is not WETH. */ error NotWeth(); /** * @dev No ETH available. */ error NoEth(); // ===================== ManagementFacet ================================ /** * @dev The assets were not withdrawn from strategy. */ error StrategyNotEmpty(); /** * @dev The strategy is already registered. */ error StrategyRegistered(); /** * @dev The strategy is already active. */ error StrategyActive(); // ===================== LibPausable ================================ /** * @dev The function is paused. * @param selector The function selector that is paused. */ error Paused(bytes4 selector); // ===================== Swapper ================================ /** * @notice Used when trying to do a swap via an exchange that is not allowed to execute a swap. * @param exchange Exchange used. */ error ExchangeNotAllowed(address exchange); /** * @notice Used when there is nothing to swap. * @param tokenIn The token that was intended to be swapped. */ error NothingToSwap(address tokenIn); /** * @notice Used when nothing was swapped. * @param tokenOut The token that was intended to be received. */ error NothingSwapped(address tokenOut); }
{ "evmVersion": "cancun", "optimizer": { "enabled": true, "runs": 10000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IWETH","name":"weth_","type":"address"},{"internalType":"contract ISwapper","name":"swapper_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NoEth","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotWeth","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"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":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"yelayLiteVault","type":"address"},{"internalType":"uint256","name":"projectId","type":"uint256"},{"components":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"address","name":"swapTarget","type":"address"},{"internalType":"bytes","name":"swapCallData","type":"bytes"}],"internalType":"struct SwapArgs","name":"swapArgs","type":"tuple"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"swapAndDeposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"swapper","outputs":[{"internalType":"contract ISwapper","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"yelayLiteVault","type":"address"},{"internalType":"uint256","name":"projectId","type":"uint256"}],"name":"wrapEthAndDeposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60e060405230608052348015610013575f5ffd5b50604051611c29380380611c298339810160408190526100329161011a565b6001600160a01b0380831660a052811660c05261004d610054565b5050610152565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100a45760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146101035780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6001600160a01b0381168114610103575f5ffd5b5f5f6040838503121561012b575f5ffd5b825161013681610106565b602084015190925061014781610106565b809150509250929050565b60805160a05160c051611a616101c85f395f818160fd015281816103f501528181610427015261055101525f8181610168015281816102c10152818161033d015281816103d10152818161078301528181610896015261092a01525f8181610f0201528181610f2b015261114c0152611a615ff3fe6080604052600436106100bb575f3560e01c806352d1902d11610071578063ad3cb1cc1161004c578063ad3cb1cc14610210578063c4d66de814610265578063f2fde38b14610284575f5ffd5b806352d1902d1461019f578063715018a6146101b35780638da5cb5b146101c7575f5ffd5b806331b8eb43116100a157806331b8eb43146101445780633fc8cef3146101575780634f1ef2861461018a575f5ffd5b806318bb27a8146100c65780632b3297f9146100ec575f5ffd5b366100c257005b5f5ffd5b6100d96100d436600461161f565b6102a3565b6040519081526020015b60405180910390f35b3480156100f7575f5ffd5b5061011f7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100e3565b6100d9610152366004611680565b61085a565b348015610162575f5ffd5b5061011f7f000000000000000000000000000000000000000000000000000000000000000081565b61019d610198366004611780565b6109f6565b005b3480156101aa575f5ffd5b506100d9610a15565b3480156101be575f5ffd5b5061019d610a43565b3480156101d2575f5ffd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1661011f565b34801561021b575f5ffd5b506102586040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516100e39190611819565b348015610270575f5ffd5b5061019d61027f36600461182b565b610a56565b34801561028f575f5ffd5b5061019d61029e36600461182b565b610bd4565b5f34156104215773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000166102ee602085018561182b565b73ffffffffffffffffffffffffffffffffffffffff161461033b576040517fc11f59c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b1580156103a1575f5ffd5b505af11580156103b3573d5f5f3e3d5ffd5b5061041c93505073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001691507f0000000000000000000000000000000000000000000000000000000000000000905034610c3c565b610472565b610472337f000000000000000000000000000000000000000000000000000000000000000084610454602088018861182b565b73ffffffffffffffffffffffffffffffffffffffff16929190610d19565b6040805160018082528183019092525f91816020015b60408051606080820183525f8083526020830152918101919091528152602001906001900390816104885790505090506104c184611846565b815f815181106104d3576104d36118cd565b60200260200101819052505f8673ffffffffffffffffffffffffffffffffffffffff16637158da7c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610528573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061054c91906118fa565b90505f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16638961ca5b84846040518363ffffffff1660e01b81526004016105aa929190611915565b6020604051808303815f875af11580156105c6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ea91906119fe565b905061060d73ffffffffffffffffffffffffffffffffffffffff83168983610e13565b6040517f8dbdbe6d000000000000000000000000000000000000000000000000000000008152600481018290526024810188905233604482015273ffffffffffffffffffffffffffffffffffffffff891690638dbdbe6d906064016020604051808303815f875af1158015610684573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106a891906119fe565b93505f6106b8602088018861182b565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015610722573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061074691906119fe565b9050801561084e57341561081f576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d906024015f604051808303815f87803b1580156107d9575f5ffd5b505af11580156107eb573d5f5f3e3d5ffd5b505060405133925083156108fc02915083905f818181858888f19350505050158015610819573d5f5f3e3d5ffd5b5061084e565b61084e338261083160208b018b61182b565b73ffffffffffffffffffffffffffffffffffffffff169190610c3c565b50505050949350505050565b5f5f3411610894576040517f3dc61b4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b1580156108fa575f5ffd5b505af115801561090c573d5f5f3e3d5ffd5b5061095593505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016915085905034610e13565b6040517f8dbdbe6d0000000000000000000000000000000000000000000000000000000081523460048201526024810183905233604482015273ffffffffffffffffffffffffffffffffffffffff841690638dbdbe6d906064016020604051808303815f875af11580156109cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109ef91906119fe565b9392505050565b6109fe610eea565b610a0782610fee565b610a118282610ff6565b5050565b5f610a1e611134565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610a4b6111a3565b610a545f611231565b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f81158015610aa05750825b90505f8267ffffffffffffffff166001148015610abc5750303b155b905081158015610aca575080155b15610b01576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b625784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b6b866112c6565b8315610bcc5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b610bdc6111a3565b73ffffffffffffffffffffffffffffffffffffffff8116610c30576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f60048201526024015b60405180910390fd5b610c3981611231565b50565b5f6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015282602482015260205f6044835f895af191505080601f3d1160015f511416151615610cac5750823b153d17155b80610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401610c27565b50505050565b5f6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015273ffffffffffffffffffffffffffffffffffffffff8416602482015282604482015260205f6064835f8a5af191505080601f3d1160015f511416151615610da55750833b153d17155b80610e0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401610c27565b5050505050565b5f6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015282602482015260205f6044835f895af191505080601f3d1160015f511416151615610e835750823b153d17155b80610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152606401610c27565b3073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161480610fb757507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16610f9e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610a54576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c396111a3565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561107b575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611078918101906119fe565b60015b6110c9576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610c27565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611125576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610c27565b61112f83836112d7565b505050565b3073ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001614610a54576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336111e27f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610a54576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610c27565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6112ce611339565b610c39816113a0565b6112e0826113a8565b60405173ffffffffffffffffffffffffffffffffffffffff8316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156113315761112f8282611476565b610a116114f5565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610a54576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bdc611339565b8073ffffffffffffffffffffffffffffffffffffffff163b5f03611410576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610c27565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60605f5f8473ffffffffffffffffffffffffffffffffffffffff168460405161149f9190611a15565b5f60405180830381855af49150503d805f81146114d7576040519150601f19603f3d011682016040523d82523d5f602084013e6114dc565b606091505b50915091506114ec85838361152d565b95945050505050565b3415610a54576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060826115425761153d826115bc565b6109ef565b8151158015611566575073ffffffffffffffffffffffffffffffffffffffff84163b155b156115b5576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610c27565b5092915050565b8051156115cc5780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610c39575f5ffd5b5f5f5f5f60808587031215611632575f5ffd5b843561163d816115fe565b935060208501359250604085013567ffffffffffffffff81111561165f575f5ffd5b850160608188031215611670575f5ffd5b9396929550929360600135925050565b5f5f60408385031215611691575f5ffd5b823561169c816115fe565b946020939093013593505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f8301126116e6575f5ffd5b813567ffffffffffffffff811115611700576117006116aa565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810167ffffffffffffffff8111828210171561174d5761174d6116aa565b604052818152838201602001851015611764575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f60408385031215611791575f5ffd5b823561179c816115fe565b9150602083013567ffffffffffffffff8111156117b7575f5ffd5b6117c3858286016116d7565b9150509250929050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081525f6109ef60208301846117cd565b5f6020828403121561183b575f5ffd5b81356109ef816115fe565b5f60608236031215611856575f5ffd5b6040516060810167ffffffffffffffff81118282101715611879576118796116aa565b6040528235611887816115fe565b81526020830135611897816115fe565b6020820152604083013567ffffffffffffffff8111156118b5575f5ffd5b6118c1368286016116d7565b60408301525092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6020828403121561190a575f5ffd5b81516109ef816115fe565b5f604082016040835280855180835260608501915060608160051b8601019250602087015f5b828110156119d7577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0878603018452815173ffffffffffffffffffffffffffffffffffffffff815116865273ffffffffffffffffffffffffffffffffffffffff602082015116602087015260408101519050606060408701526119c160608701826117cd565b955050602093840193919091019060010161193b565b50505073ffffffffffffffffffffffffffffffffffffffff851660208501525090506109ef565b5f60208284031215611a0e575f5ffd5b5051919050565b5f82518060208501845e5f92019182525091905056fea26469706673582212203477113820bbd941d05308c5d97d9ea647cf9be594a05894035dcc8348da4a0264736f6c634300081c0033000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb
Deployed Bytecode
0x6080604052600436106100bb575f3560e01c806352d1902d11610071578063ad3cb1cc1161004c578063ad3cb1cc14610210578063c4d66de814610265578063f2fde38b14610284575f5ffd5b806352d1902d1461019f578063715018a6146101b35780638da5cb5b146101c7575f5ffd5b806331b8eb43116100a157806331b8eb43146101445780633fc8cef3146101575780634f1ef2861461018a575f5ffd5b806318bb27a8146100c65780632b3297f9146100ec575f5ffd5b366100c257005b5f5ffd5b6100d96100d436600461161f565b6102a3565b6040519081526020015b60405180910390f35b3480156100f7575f5ffd5b5061011f7f000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100e3565b6100d9610152366004611680565b61085a565b348015610162575f5ffd5b5061011f7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3881565b61019d610198366004611780565b6109f6565b005b3480156101aa575f5ffd5b506100d9610a15565b3480156101be575f5ffd5b5061019d610a43565b3480156101d2575f5ffd5b507f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1661011f565b34801561021b575f5ffd5b506102586040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b6040516100e39190611819565b348015610270575f5ffd5b5061019d61027f36600461182b565b610a56565b34801561028f575f5ffd5b5061019d61029e36600461182b565b610bd4565b5f34156104215773ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38166102ee602085018561182b565b73ffffffffffffffffffffffffffffffffffffffff161461033b576040517fc11f59c500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3873ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b1580156103a1575f5ffd5b505af11580156103b3573d5f5f3e3d5ffd5b5061041c93505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381691507f000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb905034610c3c565b610472565b610472337f000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb84610454602088018861182b565b73ffffffffffffffffffffffffffffffffffffffff16929190610d19565b6040805160018082528183019092525f91816020015b60408051606080820183525f8083526020830152918101919091528152602001906001900390816104885790505090506104c184611846565b815f815181106104d3576104d36118cd565b60200260200101819052505f8673ffffffffffffffffffffffffffffffffffffffff16637158da7c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610528573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061054c91906118fa565b90505f7f000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb73ffffffffffffffffffffffffffffffffffffffff16638961ca5b84846040518363ffffffff1660e01b81526004016105aa929190611915565b6020604051808303815f875af11580156105c6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ea91906119fe565b905061060d73ffffffffffffffffffffffffffffffffffffffff83168983610e13565b6040517f8dbdbe6d000000000000000000000000000000000000000000000000000000008152600481018290526024810188905233604482015273ffffffffffffffffffffffffffffffffffffffff891690638dbdbe6d906064016020604051808303815f875af1158015610684573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106a891906119fe565b93505f6106b8602088018861182b565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff91909116906370a0823190602401602060405180830381865afa158015610722573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061074691906119fe565b9050801561084e57341561081f576040517f2e1a7d4d000000000000000000000000000000000000000000000000000000008152600481018290527f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3873ffffffffffffffffffffffffffffffffffffffff1690632e1a7d4d906024015f604051808303815f87803b1580156107d9575f5ffd5b505af11580156107eb573d5f5f3e3d5ffd5b505060405133925083156108fc02915083905f818181858888f19350505050158015610819573d5f5f3e3d5ffd5b5061084e565b61084e338261083160208b018b61182b565b73ffffffffffffffffffffffffffffffffffffffff169190610c3c565b50505050949350505050565b5f5f3411610894576040517f3dc61b4a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3873ffffffffffffffffffffffffffffffffffffffff1663d0e30db0346040518263ffffffff1660e01b81526004015f604051808303818588803b1580156108fa575f5ffd5b505af115801561090c573d5f5f3e3d5ffd5b5061095593505073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3816915085905034610e13565b6040517f8dbdbe6d0000000000000000000000000000000000000000000000000000000081523460048201526024810183905233604482015273ffffffffffffffffffffffffffffffffffffffff841690638dbdbe6d906064016020604051808303815f875af11580156109cb573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109ef91906119fe565b9392505050565b6109fe610eea565b610a0782610fee565b610a118282610ff6565b5050565b5f610a1e611134565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b610a4b6111a3565b610a545f611231565b565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff165f81158015610aa05750825b90505f8267ffffffffffffffff166001148015610abc5750303b155b905081158015610aca575080155b15610b01576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b84547fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000001660011785558315610b625784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff16680100000000000000001785555b610b6b866112c6565b8315610bcc5784547fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b610bdc6111a3565b73ffffffffffffffffffffffffffffffffffffffff8116610c30576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f60048201526024015b60405180910390fd5b610c3981611231565b50565b5f6040517fa9059cbb00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015282602482015260205f6044835f895af191505080601f3d1160015f511416151615610cac5750823b153d17155b80610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152606401610c27565b50505050565b5f6040517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015273ffffffffffffffffffffffffffffffffffffffff8416602482015282604482015260205f6064835f8a5af191505080601f3d1160015f511416151615610da55750833b153d17155b80610e0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152606401610c27565b5050505050565b5f6040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015282602482015260205f6044835f895af191505080601f3d1160015f511416151615610e835750823b153d17155b80610d13576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152606401610c27565b3073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005163531a1bba8e5616d20a313f9ecfac350c38a0161480610fb757507f0000000000000000000000005163531a1bba8e5616d20a313f9ecfac350c38a073ffffffffffffffffffffffffffffffffffffffff16610f9e7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614155b15610a54576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c396111a3565b8173ffffffffffffffffffffffffffffffffffffffff166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561107b575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252611078918101906119fe565b60015b6110c9576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83166004820152602401610c27565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611125576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610c27565b61112f83836112d7565b505050565b3073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005163531a1bba8e5616d20a313f9ecfac350c38a01614610a54576040517fe07c8dba00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b336111e27f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff1614610a54576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401610c27565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080547fffffffffffffffffffffffff0000000000000000000000000000000000000000811673ffffffffffffffffffffffffffffffffffffffff848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b6112ce611339565b610c39816113a0565b6112e0826113a8565b60405173ffffffffffffffffffffffffffffffffffffffff8316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a28051156113315761112f8282611476565b610a116114f5565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610a54576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610bdc611339565b8073ffffffffffffffffffffffffffffffffffffffff163b5f03611410576040517f4c9c8ce300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82166004820152602401610c27565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60605f5f8473ffffffffffffffffffffffffffffffffffffffff168460405161149f9190611a15565b5f60405180830381855af49150503d805f81146114d7576040519150601f19603f3d011682016040523d82523d5f602084013e6114dc565b606091505b50915091506114ec85838361152d565b95945050505050565b3415610a54576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060826115425761153d826115bc565b6109ef565b8151158015611566575073ffffffffffffffffffffffffffffffffffffffff84163b155b156115b5576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401610c27565b5092915050565b8051156115cc5780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81168114610c39575f5ffd5b5f5f5f5f60808587031215611632575f5ffd5b843561163d816115fe565b935060208501359250604085013567ffffffffffffffff81111561165f575f5ffd5b850160608188031215611670575f5ffd5b9396929550929360600135925050565b5f5f60408385031215611691575f5ffd5b823561169c816115fe565b946020939093013593505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f82601f8301126116e6575f5ffd5b813567ffffffffffffffff811115611700576117006116aa565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f0116810167ffffffffffffffff8111828210171561174d5761174d6116aa565b604052818152838201602001851015611764575f5ffd5b816020850160208301375f918101602001919091529392505050565b5f5f60408385031215611791575f5ffd5b823561179c816115fe565b9150602083013567ffffffffffffffff8111156117b7575f5ffd5b6117c3858286016116d7565b9150509250929050565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081525f6109ef60208301846117cd565b5f6020828403121561183b575f5ffd5b81356109ef816115fe565b5f60608236031215611856575f5ffd5b6040516060810167ffffffffffffffff81118282101715611879576118796116aa565b6040528235611887816115fe565b81526020830135611897816115fe565b6020820152604083013567ffffffffffffffff8111156118b5575f5ffd5b6118c1368286016116d7565b60408301525092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6020828403121561190a575f5ffd5b81516109ef816115fe565b5f604082016040835280855180835260608501915060608160051b8601019250602087015f5b828110156119d7577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0878603018452815173ffffffffffffffffffffffffffffffffffffffff815116865273ffffffffffffffffffffffffffffffffffffffff602082015116602087015260408101519050606060408701526119c160608701826117cd565b955050602093840193919091019060010161193b565b50505073ffffffffffffffffffffffffffffffffffffffff851660208501525090506109ef565b5f60208284031215611a0e575f5ffd5b5051919050565b5f82518060208501845e5f92019182525091905056fea26469706673582212203477113820bbd941d05308c5d97d9ea647cf9be594a05894035dcc8348da4a0264736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb
-----Decoded View---------------
Arg [0] : weth_ (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
Arg [1] : swapper_ (address): 0xeac44dC9bB6E6CEf3F832FF5ee32455e5E9082BB
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [1] : 000000000000000000000000eac44dc9bb6e6cef3f832ff5ee32455e5e9082bb
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.