Overview
S Balance
S Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
EulerUngovernedPerspective
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 20000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.24; import {IERC4626} from "forge-std/interfaces/IERC4626.sol"; import {EulerRouter} from "euler-price-oracle/EulerRouter.sol"; import {GenericFactory} from "evk/GenericFactory/GenericFactory.sol"; import {IEVault} from "evk/EVault/IEVault.sol"; import "evk/EVault/shared/Constants.sol"; import {IEulerRouterFactory} from "../../EulerRouterFactory/interfaces/IEulerRouterFactory.sol"; import {IEulerKinkIRMFactory} from "../../IRMFactory/interfaces/IEulerKinkIRMFactory.sol"; import {SnapshotRegistry} from "../../SnapshotRegistry/SnapshotRegistry.sol"; import {BasePerspective} from "../implementation/BasePerspective.sol"; /// @title EulerUngovernedPerspective /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A contract that verifies whether a vault has the properties of an ungoverned vault. It allows /// collaterals to be recognized by any of the specified perspectives. contract EulerUngovernedPerspective is BasePerspective { IEulerRouterFactory public immutable routerFactory; SnapshotRegistry public immutable adapterRegistry; SnapshotRegistry public immutable externalVaultRegistry; SnapshotRegistry public immutable irmRegistry; IEulerKinkIRMFactory public immutable irmFactory; string internal _name; mapping(address => bool) internal _isRecognizedUnitOfAccount; address[] internal _recognizedCollateralPerspectives; /// @notice Creates a new EulerUngovernedPerspective instance. /// @param name_ The name string for the perspective. /// @param vaultFactory_ The address of the GenericFactory contract. /// @param routerFactory_ The address of the EulerRouterFactory contract. /// @param adapterRegistry_ The address of the adapter registry contract. /// @param externalVaultRegistry_ The address of the external vault registry contract. /// @param irmFactory_ The address of the EulerKinkIRMFactory contract. /// @param irmRegistry_ The address of the IRM registry contract. /// @param recognizedUnitOfAccounts_ The addresses of the recognized unit of accounts. /// @param recognizedCollateralPerspectives_ The addresses of the recognized collateral perspectives. address(0) for /// self. constructor( string memory name_, address vaultFactory_, address routerFactory_, address adapterRegistry_, address externalVaultRegistry_, address irmFactory_, address irmRegistry_, address[] memory recognizedUnitOfAccounts_, address[] memory recognizedCollateralPerspectives_ ) BasePerspective(vaultFactory_) { _name = name_; routerFactory = IEulerRouterFactory(routerFactory_); adapterRegistry = SnapshotRegistry(adapterRegistry_); externalVaultRegistry = SnapshotRegistry(externalVaultRegistry_); irmFactory = IEulerKinkIRMFactory(irmFactory_); irmRegistry = SnapshotRegistry(irmRegistry_); for (uint256 i = 0; i < recognizedUnitOfAccounts_.length; ++i) { _isRecognizedUnitOfAccount[recognizedUnitOfAccounts_[i]] = true; } _recognizedCollateralPerspectives = recognizedCollateralPerspectives_; } /// @inheritdoc BasePerspective function name() public view virtual override returns (string memory) { return _name; } /// @notice Checks if a given unit of account is recognized by this perspective /// @param unitOfAccount The address of the unit of account to check /// @return bool True if the unit of account is recognized, false otherwise function isRecognizedUnitOfAccount(address unitOfAccount) public view returns (bool) { return _isRecognizedUnitOfAccount[unitOfAccount]; } /// @notice Returns the list of recognized collateral perspectives /// @return An array of addresses representing the recognized collateral perspectives function recognizedCollateralPerspectives() public view returns (address[] memory) { return _recognizedCollateralPerspectives; } /// @inheritdoc BasePerspective function perspectiveVerifyInternal(address vault) internal virtual override { // the vault must be deployed by recognized factory testProperty(vaultFactory.isProxy(vault), ERROR__FACTORY); // escrow vaults must be upgradeable testProperty(vaultFactory.getProxyConfig(vault).upgradeable, ERROR__UPGRADABILITY); // vaults must not be nested address asset = IEVault(vault).asset(); testProperty(!vaultFactory.isProxy(asset), ERROR__NESTING); // verify vault configuration at the governance level // vaults must not have a governor admin testProperty(IEVault(vault).governorAdmin() == address(0), ERROR__GOVERNOR); // vaults must have an interest fee in a certain range. lower bound is enforced by the vault itself testProperty(IEVault(vault).interestFee() <= 0.5e4, ERROR__INTEREST_FEE); // vaults must point to a Kink IRM instance deployed by the factory or be valid in `irmRegistry` address irm = IEVault(vault).interestRateModel(); testProperty( irmFactory.isValidDeployment(irm) || irmRegistry.isValid(irm, block.timestamp), ERROR__INTEREST_RATE_MODEL ); { // vaults must not have a hook target nor any operations disabled (address hookTarget, uint32 hookedOps) = IEVault(vault).hookConfig(); testProperty(hookTarget == address(0), ERROR__HOOK_TARGET); testProperty(hookedOps == 0, ERROR__HOOKED_OPS); } // vaults must not have any config flags set testProperty(IEVault(vault).configFlags() == 0, ERROR__CONFIG_FLAGS); // vaults must have liquidation discount in a certain range uint16 maxLiquidationDiscount = IEVault(vault).maxLiquidationDiscount(); testProperty(maxLiquidationDiscount >= 0.05e4 && maxLiquidationDiscount <= 0.2e4, ERROR__LIQUIDATION_DISCOUNT); // vaults must have certain liquidation cool off time testProperty(IEVault(vault).liquidationCoolOffTime() == 1, ERROR__LIQUIDATION_COOL_OFF_TIME); // vaults must point to an ungoverned EulerRouter instance deployed by the factory address oracle = IEVault(vault).oracle(); testProperty(routerFactory.isValidDeployment(oracle), ERROR__ORACLE_INVALID_ROUTER); testProperty(EulerRouter(oracle).governor() == address(0), ERROR__ORACLE_GOVERNED_ROUTER); testProperty(EulerRouter(oracle).fallbackOracle() == address(0), ERROR__ORACLE_INVALID_FALLBACK); // Verify the unit of account is recognized address unitOfAccount = IEVault(vault).unitOfAccount(); testProperty(_isRecognizedUnitOfAccount[unitOfAccount], ERROR__UNIT_OF_ACCOUNT); // Verify the full pricing configuration for asset/unitOfAccount in the router. verifyAssetPricing(oracle, asset, unitOfAccount); // vaults must have collaterals set up address[] memory ltvList = IEVault(vault).LTVList(); uint256 ltvListLength = ltvList.length; testProperty(ltvListLength > 0, ERROR__LTV_COLLATERAL_CONFIG_LENGTH); // vaults must have recognized collaterals for (uint256 i = 0; i < ltvListLength; ++i) { address collateral = ltvList[i]; // Verify the full pricing configuration for collateral/unitOfAccount in the router. verifyCollateralPricing(oracle, collateral, unitOfAccount); // vaults collaterals must have the LTVs set in range with LTV separation provided (uint16 borrowLTV, uint16 liquidationLTV,, uint48 targetTimestamp, uint32 rampDuration) = IEVault(vault).LTVFull(collateral); testProperty(liquidationLTV - borrowLTV >= 0.01e4, ERROR__LTV_COLLATERAL_CONFIG_SEPARATION); testProperty(borrowLTV > 0 && borrowLTV <= 0.98e4, ERROR__LTV_COLLATERAL_CONFIG_BORROW); testProperty(liquidationLTV > 0 && liquidationLTV <= 0.98e4, ERROR__LTV_COLLATERAL_CONFIG_LIQUIDATION); testProperty(rampDuration == 0 || targetTimestamp <= block.timestamp, ERROR__LTV_COLLATERAL_RAMPING); // iterate over recognized collateral perspectives to check if the collateral is recognized bool recognized = false; uint256 recognizedCollateralPerspectivesLength = _recognizedCollateralPerspectives.length; for (uint256 j = 0; j < recognizedCollateralPerspectivesLength; ++j) { address perspective = resolveRecognizedPerspective(_recognizedCollateralPerspectives[j]); if (BasePerspective(perspective).isVerified(collateral)) { recognized = true; break; } } if (!recognized) { for (uint256 j = 0; j < recognizedCollateralPerspectivesLength; ++j) { address perspective = resolveRecognizedPerspective(_recognizedCollateralPerspectives[j]); try BasePerspective(perspective).perspectiveVerify(collateral, true) { recognized = true; } catch {} if (recognized) break; } } testProperty(recognized, ERROR__LTV_COLLATERAL_RECOGNITION); } } /// @notice Validate the EulerRouter configuration of a collateral vault. /// @param router The EulerRouter instance. /// @param vault The collateral vault to verify. /// @param unitOfAccount The unit of account of the liability vault. /// @dev `vault` must be configured as a resolved vault and `verifyAssetPricing` must pass for its asset. function verifyCollateralPricing(address router, address vault, address unitOfAccount) internal { // The vault must have been configured in the router. address resolvedAsset = EulerRouter(router).resolvedVaults(vault); testProperty(resolvedAsset == IEVault(vault).asset(), ERROR__ORACLE_INVALID_ROUTER_CONFIG); // There must not be a short-circuiting adapter. testProperty( EulerRouter(router).getConfiguredOracle(vault, unitOfAccount) == address(0), ERROR__ORACLE_INVALID_ROUTER_CONFIG ); verifyAssetPricing(router, resolvedAsset, unitOfAccount); } /// @notice Validate the EulerRouter configuration of an asset. /// @param router The EulerRouter instance. /// @param asset The vault asset to verify. /// @param unitOfAccount The unit of account of the liability vault. /// @dev Valid configurations: /// 1. `asset/unitOfAccount` has a configured adapter, valid in `adapterRegistry`. /// 2. `asset` is configured as a resolved vault, valid in `externalVaultRegistry`. /// `IERC4626(asset).asset()/unitOfAccount` has a configured adapter, valid in `adapterRegistry`. /// The latter is done to accommodate ERC4626-based tokens e.g. sDai. function verifyAssetPricing(address router, address asset, address unitOfAccount) internal { // The asset must be either unresolved or a valid external vault. address unwrappedAsset = EulerRouter(router).resolvedVaults(asset); if (unwrappedAsset != address(0)) { // The asset is itself an ERC4626 resolved vault. Perform a sanity check against `IERC4626.asset()`. testProperty(IERC4626(asset).asset() == unwrappedAsset, ERROR__ORACLE_INVALID_ROUTER_CONFIG); // Verify that this vault valid in `externalVaultRegistry`. testProperty(externalVaultRegistry.isValid(asset, block.timestamp), ERROR__ORACLE_INVALID_ROUTER_CONFIG); // Additionally, there must not be a short-circuiting adapter. testProperty( EulerRouter(router).getConfiguredOracle(asset, unitOfAccount) == address(0), ERROR__ORACLE_INVALID_ROUTER_CONFIG ); } // Ignore the case where the underlying asset matches `unitOfAccount`, as the router handles that without // calling an adapter. address base = unwrappedAsset == address(0) ? asset : unwrappedAsset; if (base != unitOfAccount) { // The final adapter must be valid according to the registry. address adapter = EulerRouter(router).getConfiguredOracle(base, unitOfAccount); testProperty(adapterRegistry.isValid(adapter, block.timestamp), ERROR__ORACLE_INVALID_ADAPTER); } } /// @notice Resolves the recognized perspective address. /// @param perspective The input perspective address. /// @return The resolved perspective address. If the input is the zero address, returns the current contract /// address. function resolveRecognizedPerspective(address perspective) internal view returns (address) { if (perspective == address(0)) { return address(this); } return perspective; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2; import "./IERC20.sol"; /// @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in /// https://eips.ethereum.org/EIPS/eip-4626 interface IERC4626 is IERC20 { event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares); event Withdraw( address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares ); /// @notice Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing. /// @dev /// - MUST be an ERC-20 token contract. /// - MUST NOT revert. function asset() external view returns (address assetTokenAddress); /// @notice Returns the total amount of the underlying asset that is “managed” by Vault. /// @dev /// - SHOULD include any compounding that occurs from yield. /// - MUST be inclusive of any fees that are charged against assets in the Vault. /// - MUST NOT revert. function totalAssets() external view returns (uint256 totalManagedAssets); /// @notice Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal /// scenario where all the conditions are met. /// @dev /// - MUST NOT be inclusive of any fees that are charged against assets in the Vault. /// - MUST NOT show any variations depending on the caller. /// - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. /// - MUST NOT revert. /// /// NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the /// “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and /// from. function convertToShares(uint256 assets) external view returns (uint256 shares); /// @notice Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal /// scenario where all the conditions are met. /// @dev /// - MUST NOT be inclusive of any fees that are charged against assets in the Vault. /// - MUST NOT show any variations depending on the caller. /// - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange. /// - MUST NOT revert. /// /// NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the /// “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and /// from. function convertToAssets(uint256 shares) external view returns (uint256 assets); /// @notice Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver, /// through a deposit call. /// @dev /// - MUST return a limited value if receiver is subject to some deposit limit. /// - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited. /// - MUST NOT revert. function maxDeposit(address receiver) external view returns (uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given /// current on-chain conditions. /// @dev /// - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit /// call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called /// in the same transaction. /// - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the /// deposit would be accepted, regardless if the user has enough tokens approved, etc. /// - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. /// - MUST NOT revert. /// /// NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in /// share price or some other type of condition, meaning the depositor will lose assets by depositing. function previewDeposit(uint256 assets) external view returns (uint256 shares); /// @notice Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens. /// @dev /// - MUST emit the Deposit event. /// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the /// deposit execution, and are accounted for during deposit. /// - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not /// approving enough underlying tokens to the Vault contract, etc). /// /// NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. function deposit(uint256 assets, address receiver) external returns (uint256 shares); /// @notice Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call. /// @dev /// - MUST return a limited value if receiver is subject to some mint limit. /// - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted. /// - MUST NOT revert. function maxMint(address receiver) external view returns (uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given /// current on-chain conditions. /// @dev /// - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call /// in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the /// same transaction. /// - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint /// would be accepted, regardless if the user has enough tokens approved, etc. /// - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees. /// - MUST NOT revert. /// /// NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in /// share price or some other type of condition, meaning the depositor will lose assets by minting. function previewMint(uint256 shares) external view returns (uint256 assets); /// @notice Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens. /// @dev /// - MUST emit the Deposit event. /// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint /// execution, and are accounted for during mint. /// - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not /// approving enough underlying tokens to the Vault contract, etc). /// /// NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token. function mint(uint256 shares, address receiver) external returns (uint256 assets); /// @notice Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the /// Vault, through a withdrawal call. /// @dev /// - MUST return a limited value if owner is subject to some withdrawal limit or timelock. /// - MUST NOT revert. function maxWithdraw(address owner) external view returns (uint256 maxAssets); /// @notice Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block, /// given current on-chain conditions. /// @dev /// - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw /// call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if /// called /// in the same transaction. /// - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though /// the withdrawal would be accepted, regardless if the user has enough shares, etc. /// - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. /// - MUST NOT revert. /// /// NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in /// share price or some other type of condition, meaning the depositor will lose assets by depositing. function previewWithdraw(uint256 assets) external view returns (uint256 shares); /// @notice Burns shares from owner and sends exactly assets of underlying tokens to receiver. /// @dev /// - MUST emit the Withdraw event. /// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the /// withdraw execution, and are accounted for during withdrawal. /// - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner /// not having enough shares, etc). /// /// Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed. /// Those methods should be performed separately. function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares); /// @notice Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault, /// through a redeem call. /// @dev /// - MUST return a limited value if owner is subject to some withdrawal limit or timelock. /// - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock. /// - MUST NOT revert. function maxRedeem(address owner) external view returns (uint256 maxShares); /// @notice Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block, /// given current on-chain conditions. /// @dev /// - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call /// in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the /// same transaction. /// - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the /// redemption would be accepted, regardless if the user has enough shares, etc. /// - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees. /// - MUST NOT revert. /// /// NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in /// share price or some other type of condition, meaning the depositor will lose assets by redeeming. function previewRedeem(uint256 shares) external view returns (uint256 assets); /// @notice Burns exactly shares from owner and sends assets of underlying tokens to receiver. /// @dev /// - MUST emit the Withdraw event. /// - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the /// redeem execution, and are accounted for during redeem. /// - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner /// not having enough shares, etc). /// /// NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed. /// Those methods should be performed separately. function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {IERC4626} from "forge-std/interfaces/IERC4626.sol"; import {IPriceOracle} from "./interfaces/IPriceOracle.sol"; import {Errors} from "./lib/Errors.sol"; import {Governable} from "./lib/Governable.sol"; /// @title EulerRouter /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Default Oracle resolver for Euler lending products. /// @dev Integration Note: The router supports pricing via `convertToAssets` for trusted `resolvedVaults`. /// By ERC4626 spec `convert*` ignores liquidity restrictions, fees, slippage and per-user restrictions. /// Therefore the reported price may not be realizable through `redeem` or `withdraw`. contract EulerRouter is Governable, IPriceOracle { /// @inheritdoc IPriceOracle string public constant name = "EulerRouter"; /// @notice The PriceOracle to call if this router is not configured for base/quote. /// @dev If `address(0)` then there is no fallback. address public fallbackOracle; /// @notice ERC4626 vaults resolved using internal pricing (`convertToAssets`). mapping(address vault => address asset) public resolvedVaults; /// @notice PriceOracle configured per asset pair. /// @dev The keys are lexicographically sorted (asset0 < asset1). mapping(address asset0 => mapping(address asset1 => address oracle)) internal oracles; /// @notice Configure a PriceOracle to resolve an asset pair. /// @param asset0 The address first in lexicographic order. /// @param asset1 The address second in lexicographic order. /// @param oracle The address of the PriceOracle that resolves the pair. /// @dev If `oracle` is `address(0)` then the configuration was removed. /// The keys are lexicographically sorted (asset0 < asset1). event ConfigSet(address indexed asset0, address indexed asset1, address indexed oracle); /// @notice Set a PriceOracle as a fallback resolver. /// @param fallbackOracle The address of the PriceOracle that is called when base/quote is not configured. /// @dev If `fallbackOracle` is `address(0)` then there is no fallback resolver. event FallbackOracleSet(address indexed fallbackOracle); /// @notice Mark an ERC4626 vault to be resolved to its `asset` via its `convert*` methods. /// @param vault The address of the ERC4626 vault. /// @param asset The address of the vault's asset. /// @dev If `asset` is `address(0)` then the configuration was removed. event ResolvedVaultSet(address indexed vault, address indexed asset); /// @notice Deploy EulerRouter. /// @param _governor The address of the governor. constructor(address _evc, address _governor) Governable(_evc, _governor) { if (_governor == address(0)) revert Errors.PriceOracle_InvalidConfiguration(); } /// @notice Configure a PriceOracle to resolve base/quote and quote/base. /// @param base The address of the base token. /// @param quote The address of the quote token. /// @param oracle The address of the PriceOracle to resolve the pair. /// @dev Callable only by the governor. function govSetConfig(address base, address quote, address oracle) external onlyEVCAccountOwner onlyGovernor { // This case is handled by `resolveOracle`. if (base == quote) revert Errors.PriceOracle_InvalidConfiguration(); (address asset0, address asset1) = _sort(base, quote); oracles[asset0][asset1] = oracle; emit ConfigSet(asset0, asset1, oracle); } /// @notice Configure an ERC4626 vault to use internal pricing via `convert*` methods. /// @param vault The address of the ERC4626 vault. /// @param set True to configure the vault, false to clear the record. /// @dev Callable only by the governor. Vault must implement ERC4626. /// Note: Before configuring a vault verify that its `convertToAssets` is secure. function govSetResolvedVault(address vault, bool set) external onlyEVCAccountOwner onlyGovernor { address asset = set ? IERC4626(vault).asset() : address(0); resolvedVaults[vault] = asset; emit ResolvedVaultSet(vault, asset); } /// @notice Set a PriceOracle as a fallback resolver. /// @param _fallbackOracle The address of the PriceOracle that is called when base/quote is not configured. /// @dev Callable only by the governor. `address(0)` removes the fallback. function govSetFallbackOracle(address _fallbackOracle) external onlyEVCAccountOwner onlyGovernor { fallbackOracle = _fallbackOracle; emit FallbackOracleSet(_fallbackOracle); } /// @inheritdoc IPriceOracle function getQuote(uint256 inAmount, address base, address quote) external view returns (uint256) { address oracle; (inAmount, base, quote, oracle) = resolveOracle(inAmount, base, quote); if (base == quote) return inAmount; return IPriceOracle(oracle).getQuote(inAmount, base, quote); } /// @inheritdoc IPriceOracle function getQuotes(uint256 inAmount, address base, address quote) external view returns (uint256, uint256) { address oracle; (inAmount, base, quote, oracle) = resolveOracle(inAmount, base, quote); if (base == quote) return (inAmount, inAmount); return IPriceOracle(oracle).getQuotes(inAmount, base, quote); } /// @notice Get the PriceOracle configured for base/quote. /// @param base The address of the base token. /// @param quote The address of the quote token. /// @return The configured `PriceOracle` for the pair or `address(0)` if no oracle is configured. function getConfiguredOracle(address base, address quote) public view returns (address) { (address asset0, address asset1) = _sort(base, quote); return oracles[asset0][asset1]; } /// @notice Resolve the PriceOracle to call for a given base/quote pair. /// @param inAmount The amount of `base` to convert. /// @param base The token that is being priced. /// @param quote The token that is the unit of account. /// @dev Implements the following resolution logic: /// 1. Check the base case: `base == quote` and terminate if true. /// 2. If a PriceOracle is configured for base/quote in the `oracles` mapping, return it. /// 3. If `base` is configured as a resolved ERC4626 vault, call `convertToAssets(inAmount)` /// and continue the recursion, substituting the ERC4626 `asset` for `base`. /// 4. As a last resort, return the fallback oracle or revert if it is not set. /// @return The resolved amount. This value may be different from the original `inAmount` /// if the resolution path included an ERC4626 vault present in `resolvedVaults`. /// @return The resolved base. /// @return The resolved quote. /// @return The resolved PriceOracle to call. function resolveOracle(uint256 inAmount, address base, address quote) public view returns (uint256, /* resolvedAmount */ address, /* base */ address, /* quote */ address /* oracle */ ) { // 1. Check the base case. if (base == quote) return (inAmount, base, quote, address(0)); // 2. Check if there is a PriceOracle configured for base/quote. address oracle = getConfiguredOracle(base, quote); if (oracle != address(0)) return (inAmount, base, quote, oracle); // 3. Recursively resolve `base`. address baseAsset = resolvedVaults[base]; if (baseAsset != address(0)) { inAmount = IERC4626(base).convertToAssets(inAmount); return resolveOracle(inAmount, baseAsset, quote); } // 4. Return the fallback or revert if not configured. oracle = fallbackOracle; if (oracle == address(0)) revert Errors.PriceOracle_NotSupported(base, quote); return (inAmount, base, quote, oracle); } /// @notice Lexicographically sort two addresses. /// @param assetA One of the assets in the pair. /// @param assetB The other asset in the pair. /// @return The address first in lexicographic order. /// @return The address second in lexicographic order. function _sort(address assetA, address assetB) internal pure returns (address, address) { return assetA < assetB ? (assetA, assetB) : (assetB, assetA); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {BeaconProxy} from "./BeaconProxy.sol"; import {MetaProxyDeployer} from "./MetaProxyDeployer.sol"; /// @title IComponent /// @notice Minimal interface which must be implemented by the contract deployed by the factory interface IComponent { /// @notice Function replacing the constructor in proxied contracts /// @param creator The new contract's creator address function initialize(address creator) external; } /// @title GenericFactory /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice The factory allows permissionless creation of upgradeable or non-upgradeable proxy contracts and serves as a /// beacon for the upgradeable ones contract GenericFactory is MetaProxyDeployer { // Constants uint256 internal constant REENTRANCYLOCK__UNLOCKED = 1; uint256 internal constant REENTRANCYLOCK__LOCKED = 2; // State /// @title ProxyConfig /// @notice This struct is used to store the configuration of a proxy deployed by the factory struct ProxyConfig { // If true, proxy is an instance of the BeaconProxy bool upgradeable; // Address of the implementation contract // May be an out-of-date value, if upgradeable (handled by getProxyConfig) address implementation; // The metadata attached to every call passing through the proxy bytes trailingData; } uint256 private reentrancyLock; /// @notice Address of the account authorized to upgrade the implementation contract address public upgradeAdmin; /// @notice Address of the implementation contract, which the deployed proxies will delegate-call to /// @dev The contract must implement the `IComponent` interface address public implementation; /// @notice A lookup for configurations of the proxy contracts deployed by the factory mapping(address proxy => ProxyConfig) internal proxyLookup; /// @notice An array of addresses of all the proxies deployed by the factory address[] public proxyList; // Events /// @notice The factory is created event Genesis(); /// @notice A new proxy is created /// @param proxy Address of the new proxy /// @param upgradeable If true, proxy is an instance of the BeaconProxy. If false, the proxy is a minimal meta proxy /// @param implementation Address of the implementation contract, at the time the proxy was deployed /// @param trailingData The metadata that will be attached to every call passing through the proxy event ProxyCreated(address indexed proxy, bool upgradeable, address implementation, bytes trailingData); /// @notice Set a new implementation contract. All the BeaconProxies are upgraded to the new logic /// @param newImplementation Address of the new implementation contract event SetImplementation(address indexed newImplementation); /// @notice Set a new upgrade admin /// @param newUpgradeAdmin Address of the new admin event SetUpgradeAdmin(address indexed newUpgradeAdmin); // Errors error E_Reentrancy(); error E_Unauthorized(); error E_Implementation(); error E_BadAddress(); error E_BadQuery(); // Modifiers modifier nonReentrant() { if (reentrancyLock == REENTRANCYLOCK__LOCKED) revert E_Reentrancy(); reentrancyLock = REENTRANCYLOCK__LOCKED; _; reentrancyLock = REENTRANCYLOCK__UNLOCKED; } modifier adminOnly() { if (msg.sender != upgradeAdmin) revert E_Unauthorized(); _; } constructor(address admin) { emit Genesis(); if (admin == address(0)) revert E_BadAddress(); reentrancyLock = REENTRANCYLOCK__UNLOCKED; upgradeAdmin = admin; emit SetUpgradeAdmin(admin); } /// @notice A permissionless funtion to deploy new proxies /// @param desiredImplementation Address of the implementation contract expected to be registered in the factory /// during proxy creation /// @param upgradeable If true, the proxy will be an instance of the BeaconProxy. If false, a minimal meta proxy /// will be deployed /// @param trailingData Metadata to be attached to every call passing through the new proxy /// @return The address of the new proxy /// @dev The desired implementation serves as a protection against (unintentional) front-running of upgrades function createProxy(address desiredImplementation, bool upgradeable, bytes memory trailingData) external nonReentrant returns (address) { address _implementation = implementation; if (desiredImplementation == address(0)) desiredImplementation = _implementation; if (desiredImplementation == address(0) || desiredImplementation != _implementation) revert E_Implementation(); // The provided trailing data is prefixed with 4 zero bytes to avoid potential selector clashing in case the // proxy is called with empty calldata. bytes memory prefixTrailingData = abi.encodePacked(bytes4(0), trailingData); address proxy; if (upgradeable) { proxy = address(new BeaconProxy(prefixTrailingData)); } else { proxy = deployMetaProxy(desiredImplementation, prefixTrailingData); } proxyLookup[proxy] = ProxyConfig({upgradeable: upgradeable, implementation: desiredImplementation, trailingData: trailingData}); proxyList.push(proxy); IComponent(proxy).initialize(msg.sender); emit ProxyCreated(proxy, upgradeable, desiredImplementation, trailingData); return proxy; } // EVault beacon upgrade /// @notice Set a new implementation contract /// @param newImplementation Address of the new implementation contract /// @dev Upgrades all existing BeaconProxies to the new logic immediately function setImplementation(address newImplementation) external nonReentrant adminOnly { if (newImplementation.code.length == 0) revert E_BadAddress(); implementation = newImplementation; emit SetImplementation(newImplementation); } // Admin role /// @notice Transfer admin rights to a new address /// @param newUpgradeAdmin Address of the new admin /// @dev For creating non upgradeable factories, or to finalize all upgradeable proxies to current implementation, /// @dev set the admin to zero address. /// @dev If setting to address zero, make sure the implementation contract is already set function setUpgradeAdmin(address newUpgradeAdmin) external nonReentrant adminOnly { upgradeAdmin = newUpgradeAdmin; emit SetUpgradeAdmin(newUpgradeAdmin); } // Proxy getters /// @notice Get current proxy configuration /// @param proxy Address of the proxy to query /// @return config The proxy's configuration, including current implementation function getProxyConfig(address proxy) external view returns (ProxyConfig memory config) { config = proxyLookup[proxy]; if (config.upgradeable) config.implementation = implementation; } /// @notice Check if an address is a proxy deployed with this factory /// @param proxy Address to check /// @return True if the address is a proxy function isProxy(address proxy) external view returns (bool) { return proxyLookup[proxy].implementation != address(0); } /// @notice Fetch the length of the deployed proxies list /// @return The length of the proxy list array function getProxyListLength() external view returns (uint256) { return proxyList.length; } /// @notice Get a slice of the deployed proxies array /// @param start Start index of the slice /// @param end End index of the slice /// @return list An array containing the slice of the proxy list function getProxyListSlice(uint256 start, uint256 end) external view returns (address[] memory list) { if (end == type(uint256).max) end = proxyList.length; if (end < start || end > proxyList.length) revert E_BadQuery(); list = new address[](end - start); for (uint256 i; i < end - start; ++i) { list[i] = proxyList[start + i]; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; import {IVault as IEVCVault} from "ethereum-vault-connector/interfaces/IVault.sol"; // Full interface of EVault and all it's modules /// @title IInitialize /// @notice Interface of the initialization module of EVault interface IInitialize { /// @notice Initialization of the newly deployed proxy contract /// @param proxyCreator Account which created the proxy or should be the initial governor function initialize(address proxyCreator) external; } /// @title IERC20 /// @notice Interface of the EVault's Initialize module interface IERC20 { /// @notice Vault share token (eToken) name, ie "Euler Vault: DAI" /// @return The name of the eToken function name() external view returns (string memory); /// @notice Vault share token (eToken) symbol, ie "eDAI" /// @return The symbol of the eToken function symbol() external view returns (string memory); /// @notice Decimals, the same as the asset's or 18 if the asset doesn't implement `decimals()` /// @return The decimals of the eToken function decimals() external view returns (uint8); /// @notice Sum of all eToken balances /// @return The total supply of the eToken function totalSupply() external view returns (uint256); /// @notice Balance of a particular account, in eTokens /// @param account Address to query /// @return The balance of the account function balanceOf(address account) external view returns (uint256); /// @notice Retrieve the current allowance /// @param holder The account holding the eTokens /// @param spender Trusted address /// @return The allowance from holder for spender function allowance(address holder, address spender) external view returns (uint256); /// @notice Transfer eTokens to another address /// @param to Recipient account /// @param amount In shares. /// @return True if transfer succeeded function transfer(address to, uint256 amount) external returns (bool); /// @notice Transfer eTokens from one address to another /// @param from This address must've approved the to address /// @param to Recipient account /// @param amount In shares /// @return True if transfer succeeded function transferFrom(address from, address to, uint256 amount) external returns (bool); /// @notice Allow spender to access an amount of your eTokens /// @param spender Trusted address /// @param amount Use max uint for "infinite" allowance /// @return True if approval succeeded function approve(address spender, uint256 amount) external returns (bool); } /// @title IToken /// @notice Interface of the EVault's Token module interface IToken is IERC20 { /// @notice Transfer the full eToken balance of an address to another /// @param from This address must've approved the to address /// @param to Recipient account /// @return True if transfer succeeded function transferFromMax(address from, address to) external returns (bool); } /// @title IERC4626 /// @notice Interface of an ERC4626 vault interface IERC4626 { /// @notice Vault's underlying asset /// @return The vault's underlying asset function asset() external view returns (address); /// @notice Total amount of managed assets, cash and borrows /// @return The total amount of assets function totalAssets() external view returns (uint256); /// @notice Calculate amount of assets corresponding to the requested shares amount /// @param shares Amount of shares to convert /// @return The amount of assets function convertToAssets(uint256 shares) external view returns (uint256); /// @notice Calculate amount of shares corresponding to the requested assets amount /// @param assets Amount of assets to convert /// @return The amount of shares function convertToShares(uint256 assets) external view returns (uint256); /// @notice Fetch the maximum amount of assets a user can deposit /// @param account Address to query /// @return The max amount of assets the account can deposit function maxDeposit(address account) external view returns (uint256); /// @notice Calculate an amount of shares that would be created by depositing assets /// @param assets Amount of assets deposited /// @return Amount of shares received function previewDeposit(uint256 assets) external view returns (uint256); /// @notice Fetch the maximum amount of shares a user can mint /// @param account Address to query /// @return The max amount of shares the account can mint function maxMint(address account) external view returns (uint256); /// @notice Calculate an amount of assets that would be required to mint requested amount of shares /// @param shares Amount of shares to be minted /// @return Required amount of assets function previewMint(uint256 shares) external view returns (uint256); /// @notice Fetch the maximum amount of assets a user is allowed to withdraw /// @param owner Account holding the shares /// @return The maximum amount of assets the owner is allowed to withdraw function maxWithdraw(address owner) external view returns (uint256); /// @notice Calculate the amount of shares that will be burned when withdrawing requested amount of assets /// @param assets Amount of assets withdrawn /// @return Amount of shares burned function previewWithdraw(uint256 assets) external view returns (uint256); /// @notice Fetch the maximum amount of shares a user is allowed to redeem for assets /// @param owner Account holding the shares /// @return The maximum amount of shares the owner is allowed to redeem function maxRedeem(address owner) external view returns (uint256); /// @notice Calculate the amount of assets that will be transferred when redeeming requested amount of shares /// @param shares Amount of shares redeemed /// @return Amount of assets transferred function previewRedeem(uint256 shares) external view returns (uint256); /// @notice Transfer requested amount of underlying tokens from sender to the vault pool in return for shares /// @param amount Amount of assets to deposit (use max uint256 for full underlying token balance) /// @param receiver An account to receive the shares /// @return Amount of shares minted /// @dev Deposit will round down the amount of assets that are converted to shares. To prevent losses consider using /// mint instead. function deposit(uint256 amount, address receiver) external returns (uint256); /// @notice Transfer underlying tokens from sender to the vault pool in return for requested amount of shares /// @param amount Amount of shares to be minted /// @param receiver An account to receive the shares /// @return Amount of assets deposited function mint(uint256 amount, address receiver) external returns (uint256); /// @notice Transfer requested amount of underlying tokens from the vault and decrease account's shares balance /// @param amount Amount of assets to withdraw /// @param receiver Account to receive the withdrawn assets /// @param owner Account holding the shares to burn /// @return Amount of shares burned function withdraw(uint256 amount, address receiver, address owner) external returns (uint256); /// @notice Burn requested shares and transfer corresponding underlying tokens from the vault to the receiver /// @param amount Amount of shares to burn (use max uint256 to burn full owner balance) /// @param receiver Account to receive the withdrawn assets /// @param owner Account holding the shares to burn. /// @return Amount of assets transferred function redeem(uint256 amount, address receiver, address owner) external returns (uint256); } /// @title IVault /// @notice Interface of the EVault's Vault module interface IVault is IERC4626 { /// @notice Balance of the fees accumulator, in shares /// @return The accumulated fees in shares function accumulatedFees() external view returns (uint256); /// @notice Balance of the fees accumulator, in underlying units /// @return The accumulated fees in asset units function accumulatedFeesAssets() external view returns (uint256); /// @notice Address of the original vault creator /// @return The address of the creator function creator() external view returns (address); /// @notice Creates shares for the receiver, from excess asset balances of the vault (not accounted for in `cash`) /// @param amount Amount of assets to claim (use max uint256 to claim all available assets) /// @param receiver An account to receive the shares /// @return Amount of shares minted /// @dev Could be used as an alternative deposit flow in certain scenarios. E.g. swap directly to the vault, call /// `skim` to claim deposit. function skim(uint256 amount, address receiver) external returns (uint256); } /// @title IBorrowing /// @notice Interface of the EVault's Borrowing module interface IBorrowing { /// @notice Sum of all outstanding debts, in underlying units (increases as interest is accrued) /// @return The total borrows in asset units function totalBorrows() external view returns (uint256); /// @notice Sum of all outstanding debts, in underlying units scaled up by shifting /// INTERNAL_DEBT_PRECISION_SHIFT bits /// @return The total borrows in internal debt precision function totalBorrowsExact() external view returns (uint256); /// @notice Balance of vault assets as tracked by deposits/withdrawals and borrows/repays /// @return The amount of assets the vault tracks as current direct holdings function cash() external view returns (uint256); /// @notice Debt owed by a particular account, in underlying units /// @param account Address to query /// @return The debt of the account in asset units function debtOf(address account) external view returns (uint256); /// @notice Debt owed by a particular account, in underlying units scaled up by shifting /// INTERNAL_DEBT_PRECISION_SHIFT bits /// @param account Address to query /// @return The debt of the account in internal precision function debtOfExact(address account) external view returns (uint256); /// @notice Retrieves the current interest rate for an asset /// @return The interest rate in yield-per-second, scaled by 10**27 function interestRate() external view returns (uint256); /// @notice Retrieves the current interest rate accumulator for an asset /// @return An opaque accumulator that increases as interest is accrued function interestAccumulator() external view returns (uint256); /// @notice Returns an address of the sidecar DToken /// @return The address of the DToken function dToken() external view returns (address); /// @notice Transfer underlying tokens from the vault to the sender, and increase sender's debt /// @param amount Amount of assets to borrow (use max uint256 for all available tokens) /// @param receiver Account receiving the borrowed tokens /// @return Amount of assets borrowed function borrow(uint256 amount, address receiver) external returns (uint256); /// @notice Transfer underlying tokens from the sender to the vault, and decrease receiver's debt /// @param amount Amount of debt to repay in assets (use max uint256 for full debt) /// @param receiver Account holding the debt to be repaid /// @return Amount of assets repaid function repay(uint256 amount, address receiver) external returns (uint256); /// @notice Pay off liability with shares ("self-repay") /// @param amount In asset units (use max uint256 to repay the debt in full or up to the available deposit) /// @param receiver Account to remove debt from by burning sender's shares /// @return shares Amount of shares burned /// @return debt Amount of debt removed in assets /// @dev Equivalent to withdrawing and repaying, but no assets are needed to be present in the vault /// @dev Contrary to a regular `repay`, if account is unhealthy, the repay amount must bring the account back to /// health, or the operation will revert during account status check function repayWithShares(uint256 amount, address receiver) external returns (uint256 shares, uint256 debt); /// @notice Take over debt from another account /// @param amount Amount of debt in asset units (use max uint256 for all the account's debt) /// @param from Account to pull the debt from /// @dev Due to internal debt precision accounting, the liability reported on either or both accounts after /// calling `pullDebt` may not match the `amount` requested precisely function pullDebt(uint256 amount, address from) external; /// @notice Request a flash-loan. A onFlashLoan() callback in msg.sender will be invoked, which must repay the loan /// to the main Euler address prior to returning. /// @param amount In asset units /// @param data Passed through to the onFlashLoan() callback, so contracts don't need to store transient data in /// storage function flashLoan(uint256 amount, bytes calldata data) external; /// @notice Updates interest accumulator and totalBorrows, credits reserves, re-targets interest rate, and logs /// vault status function touch() external; } /// @title ILiquidation /// @notice Interface of the EVault's Liquidation module interface ILiquidation { /// @notice Checks to see if a liquidation would be profitable, without actually doing anything /// @param liquidator Address that will initiate the liquidation /// @param violator Address that may be in collateral violation /// @param collateral Collateral which is to be seized /// @return maxRepay Max amount of debt that can be repaid, in asset units /// @return maxYield Yield in collateral corresponding to max allowed amount of debt to be repaid, in collateral /// balance (shares for vaults) function checkLiquidation(address liquidator, address violator, address collateral) external view returns (uint256 maxRepay, uint256 maxYield); /// @notice Attempts to perform a liquidation /// @param violator Address that may be in collateral violation /// @param collateral Collateral which is to be seized /// @param repayAssets The amount of underlying debt to be transferred from violator to sender, in asset units (use /// max uint256 to repay the maximum possible amount). Meant as slippage check together with `minYieldBalance` /// @param minYieldBalance The minimum acceptable amount of collateral to be transferred from violator to sender, in /// collateral balance units (shares for vaults). Meant as slippage check together with `repayAssets` /// @dev If `repayAssets` is set to max uint256 it is assumed the caller will perform their own slippage checks to /// make sure they are not taking on too much debt. This option is mainly meant for smart contract liquidators function liquidate(address violator, address collateral, uint256 repayAssets, uint256 minYieldBalance) external; } /// @title IRiskManager /// @notice Interface of the EVault's RiskManager module interface IRiskManager is IEVCVault { /// @notice Retrieve account's total liquidity /// @param account Account holding debt in this vault /// @param liquidation Flag to indicate if the calculation should be performed in liquidation vs account status /// check mode, where different LTV values might apply. /// @return collateralValue Total risk adjusted value of all collaterals in unit of account /// @return liabilityValue Value of debt in unit of account function accountLiquidity(address account, bool liquidation) external view returns (uint256 collateralValue, uint256 liabilityValue); /// @notice Retrieve account's liquidity per collateral /// @param account Account holding debt in this vault /// @param liquidation Flag to indicate if the calculation should be performed in liquidation vs account status /// check mode, where different LTV values might apply. /// @return collaterals Array of collaterals enabled /// @return collateralValues Array of risk adjusted collateral values corresponding to items in collaterals array. /// In unit of account /// @return liabilityValue Value of debt in unit of account function accountLiquidityFull(address account, bool liquidation) external view returns (address[] memory collaterals, uint256[] memory collateralValues, uint256 liabilityValue); /// @notice Release control of the account on EVC if no outstanding debt is present function disableController() external; /// @notice Checks the status of an account and reverts if account is not healthy /// @param account The address of the account to be checked /// @return magicValue Must return the bytes4 magic value 0xb168c58f (which is a selector of this function) when /// account status is valid, or revert otherwise. /// @dev Only callable by EVC during status checks function checkAccountStatus(address account, address[] calldata collaterals) external view returns (bytes4); /// @notice Checks the status of the vault and reverts if caps are exceeded /// @return magicValue Must return the bytes4 magic value 0x4b3d1223 (which is a selector of this function) when /// account status is valid, or revert otherwise. /// @dev Only callable by EVC during status checks function checkVaultStatus() external returns (bytes4); } /// @title IBalanceForwarder /// @notice Interface of the EVault's BalanceForwarder module interface IBalanceForwarder { /// @notice Retrieve the address of rewards contract, tracking changes in account's balances /// @return The balance tracker address function balanceTrackerAddress() external view returns (address); /// @notice Retrieves boolean indicating if the account opted in to forward balance changes to the rewards contract /// @param account Address to query /// @return True if balance forwarder is enabled function balanceForwarderEnabled(address account) external view returns (bool); /// @notice Enables balance forwarding for the authenticated account /// @dev Only the authenticated account can enable balance forwarding for itself /// @dev Should call the IBalanceTracker hook with the current account's balance function enableBalanceForwarder() external; /// @notice Disables balance forwarding for the authenticated account /// @dev Only the authenticated account can disable balance forwarding for itself /// @dev Should call the IBalanceTracker hook with the account's balance of 0 function disableBalanceForwarder() external; } /// @title IGovernance /// @notice Interface of the EVault's Governance module interface IGovernance { /// @notice Retrieves the address of the governor /// @return The governor address function governorAdmin() external view returns (address); /// @notice Retrieves address of the governance fee receiver /// @return The fee receiver address function feeReceiver() external view returns (address); /// @notice Retrieves the interest fee in effect for the vault /// @return Amount of interest that is redirected as a fee, as a fraction scaled by 1e4 function interestFee() external view returns (uint16); /// @notice Looks up an asset's currently configured interest rate model /// @return Address of the interest rate contract or address zero to indicate 0% interest function interestRateModel() external view returns (address); /// @notice Retrieves the ProtocolConfig address /// @return The protocol config address function protocolConfigAddress() external view returns (address); /// @notice Retrieves the protocol fee share /// @return A percentage share of fees accrued belonging to the protocol, in 1e4 scale function protocolFeeShare() external view returns (uint256); /// @notice Retrieves the address which will receive protocol's fees /// @notice The protocol fee receiver address function protocolFeeReceiver() external view returns (address); /// @notice Retrieves supply and borrow caps in AmountCap format /// @return supplyCap The supply cap in AmountCap format /// @return borrowCap The borrow cap in AmountCap format function caps() external view returns (uint16 supplyCap, uint16 borrowCap); /// @notice Retrieves the borrow LTV of the collateral, which is used to determine if the account is healthy during /// account status checks. /// @param collateral The address of the collateral to query /// @return Borrowing LTV in 1e4 scale function LTVBorrow(address collateral) external view returns (uint16); /// @notice Retrieves the current liquidation LTV, which is used to determine if the account is eligible for /// liquidation /// @param collateral The address of the collateral to query /// @return Liquidation LTV in 1e4 scale function LTVLiquidation(address collateral) external view returns (uint16); /// @notice Retrieves LTV configuration for the collateral /// @param collateral Collateral asset /// @return borrowLTV The current value of borrow LTV for originating positions /// @return liquidationLTV The value of fully converged liquidation LTV /// @return initialLiquidationLTV The initial value of the liquidation LTV, when the ramp began /// @return targetTimestamp The timestamp when the liquidation LTV is considered fully converged /// @return rampDuration The time it takes for the liquidation LTV to converge from the initial value to the fully /// converged value function LTVFull(address collateral) external view returns ( uint16 borrowLTV, uint16 liquidationLTV, uint16 initialLiquidationLTV, uint48 targetTimestamp, uint32 rampDuration ); /// @notice Retrieves a list of collaterals with configured LTVs /// @return List of asset collaterals /// @dev Returned assets could have the ltv disabled (set to zero) function LTVList() external view returns (address[] memory); /// @notice Retrieves the maximum liquidation discount /// @return The maximum liquidation discount in 1e4 scale /// @dev The default value, which is zero, is deliberately bad, as it means there would be no incentive to liquidate /// unhealthy users. The vault creator must take care to properly select the limit, given the underlying and /// collaterals used. function maxLiquidationDiscount() external view returns (uint16); /// @notice Retrieves liquidation cool-off time, which must elapse after successful account status check before /// account can be liquidated /// @return The liquidation cool off time in seconds function liquidationCoolOffTime() external view returns (uint16); /// @notice Retrieves a hook target and a bitmask indicating which operations call the hook target /// @return hookTarget Address of the hook target contract /// @return hookedOps Bitmask with operations that should call the hooks. See Constants.sol for a list of operations function hookConfig() external view returns (address hookTarget, uint32 hookedOps); /// @notice Retrieves a bitmask indicating enabled config flags /// @return Bitmask with config flags enabled function configFlags() external view returns (uint32); /// @notice Address of EthereumVaultConnector contract /// @return The EVC address function EVC() external view returns (address); /// @notice Retrieves a reference asset used for liquidity calculations /// @return The address of the reference asset function unitOfAccount() external view returns (address); /// @notice Retrieves the address of the oracle contract /// @return The address of the oracle function oracle() external view returns (address); /// @notice Retrieves the Permit2 contract address /// @return The address of the Permit2 contract function permit2Address() external view returns (address); /// @notice Splits accrued fees balance according to protocol fee share and transfers shares to the governor fee /// receiver and protocol fee receiver function convertFees() external; /// @notice Set a new governor address /// @param newGovernorAdmin The new governor address /// @dev Set to zero address to renounce privileges and make the vault non-governed function setGovernorAdmin(address newGovernorAdmin) external; /// @notice Set a new governor fee receiver address /// @param newFeeReceiver The new fee receiver address function setFeeReceiver(address newFeeReceiver) external; /// @notice Set a new LTV config /// @param collateral Address of collateral to set LTV for /// @param borrowLTV New borrow LTV, for assessing account's health during account status checks, in 1e4 scale /// @param liquidationLTV New liquidation LTV after ramp ends in 1e4 scale /// @param rampDuration Ramp duration in seconds function setLTV(address collateral, uint16 borrowLTV, uint16 liquidationLTV, uint32 rampDuration) external; /// @notice Set a new maximum liquidation discount /// @param newDiscount New maximum liquidation discount in 1e4 scale /// @dev If the discount is zero (the default), the liquidators will not be incentivized to liquidate unhealthy /// accounts function setMaxLiquidationDiscount(uint16 newDiscount) external; /// @notice Set a new liquidation cool off time, which must elapse after successful account status check before /// account can be liquidated /// @param newCoolOffTime The new liquidation cool off time in seconds /// @dev Setting cool off time to zero allows liquidating the account in the same block as the last successful /// account status check function setLiquidationCoolOffTime(uint16 newCoolOffTime) external; /// @notice Set a new interest rate model contract /// @param newModel The new IRM address /// @dev If the new model reverts, perhaps due to governor error, the vault will silently use a zero interest /// rate. Governor should make sure the new interest rates are computed as expected. function setInterestRateModel(address newModel) external; /// @notice Set a new hook target and a new bitmap indicating which operations should call the hook target. /// Operations are defined in Constants.sol. /// @param newHookTarget The new hook target address. Use address(0) to simply disable hooked operations /// @param newHookedOps Bitmask with the new hooked operations /// @dev All operations are initially disabled in a newly created vault. The vault creator must set their /// own configuration to make the vault usable function setHookConfig(address newHookTarget, uint32 newHookedOps) external; /// @notice Set new bitmap indicating which config flags should be enabled. Flags are defined in Constants.sol /// @param newConfigFlags Bitmask with the new config flags function setConfigFlags(uint32 newConfigFlags) external; /// @notice Set new supply and borrow caps in AmountCap format /// @param supplyCap The new supply cap in AmountCap fromat /// @param borrowCap The new borrow cap in AmountCap fromat function setCaps(uint16 supplyCap, uint16 borrowCap) external; /// @notice Set a new interest fee /// @param newFee The new interest fee function setInterestFee(uint16 newFee) external; } /// @title IEVault /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Interface of the EVault, an EVC enabled lending vault interface IEVault is IInitialize, IToken, IVault, IBorrowing, ILiquidation, IRiskManager, IBalanceForwarder, IGovernance { /// @notice Fetch address of the `Initialize` module function MODULE_INITIALIZE() external view returns (address); /// @notice Fetch address of the `Token` module function MODULE_TOKEN() external view returns (address); /// @notice Fetch address of the `Vault` module function MODULE_VAULT() external view returns (address); /// @notice Fetch address of the `Borrowing` module function MODULE_BORROWING() external view returns (address); /// @notice Fetch address of the `Liquidation` module function MODULE_LIQUIDATION() external view returns (address); /// @notice Fetch address of the `RiskManager` module function MODULE_RISKMANAGER() external view returns (address); /// @notice Fetch address of the `BalanceForwarder` module function MODULE_BALANCE_FORWARDER() external view returns (address); /// @notice Fetch address of the `Governance` module function MODULE_GOVERNANCE() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; // Implementation internals // asset amounts are shifted left by this number of bits for increased precision of debt tracking. uint256 constant INTERNAL_DEBT_PRECISION_SHIFT = 31; // max amount for Assets and Shares custom types based on a uint112. uint256 constant MAX_SANE_AMOUNT = type(uint112).max; // max debt amount fits in uint144 (112 + 31 bits). // Last 31 bits are zeros to ensure max debt rounded up equals max sane amount. uint256 constant MAX_SANE_DEBT_AMOUNT = uint256(MAX_SANE_AMOUNT) << INTERNAL_DEBT_PRECISION_SHIFT; // proxy trailing calldata length in bytes. // Three addresses, 20 bytes each: vault underlying asset, oracle and unit of account + 4 empty bytes. uint256 constant PROXY_METADATA_LENGTH = 64; // gregorian calendar uint256 constant SECONDS_PER_YEAR = 365.2425 * 86400; // max interest rate accepted from IRM. 1,000,000% APY: floor(((1000000 / 100 + 1)**(1/(86400*365.2425)) - 1) * 1e27) uint256 constant MAX_ALLOWED_INTEREST_RATE = 291867278914945094175; // max valid value of the ConfigAmount custom type, signifying 100% uint16 constant CONFIG_SCALE = 1e4; // Account status checks special values // no account status checks should be scheduled address constant CHECKACCOUNT_NONE = address(0); // account status check should be scheduled for the authenticated account address constant CHECKACCOUNT_CALLER = address(1); // Operations uint32 constant OP_DEPOSIT = 1 << 0; uint32 constant OP_MINT = 1 << 1; uint32 constant OP_WITHDRAW = 1 << 2; uint32 constant OP_REDEEM = 1 << 3; uint32 constant OP_TRANSFER = 1 << 4; uint32 constant OP_SKIM = 1 << 5; uint32 constant OP_BORROW = 1 << 6; uint32 constant OP_REPAY = 1 << 7; uint32 constant OP_REPAY_WITH_SHARES = 1 << 8; uint32 constant OP_PULL_DEBT = 1 << 9; uint32 constant OP_CONVERT_FEES = 1 << 10; uint32 constant OP_LIQUIDATE = 1 << 11; uint32 constant OP_FLASHLOAN = 1 << 12; uint32 constant OP_TOUCH = 1 << 13; uint32 constant OP_VAULT_STATUS_CHECK = 1 << 14; // Delimiter of possible operations uint32 constant OP_MAX_VALUE = 1 << 15; // Config Flags // When flag is set, debt socialization during liquidation is disabled uint32 constant CFG_DONT_SOCIALIZE_DEBT = 1 << 0; // When flag is set, asset is considered to be compatible with EVC sub-accounts and protections // against sending assets to sub-accounts are disabled uint32 constant CFG_EVC_COMPATIBLE_ASSET = 1 << 1; // Delimiter of possible config flags uint32 constant CFG_MAX_VALUE = 1 << 2; // EVC authentication // in order to perform these operations, the account doesn't need to have the vault installed as a controller uint32 constant CONTROLLER_NEUTRAL_OPS = OP_DEPOSIT | OP_MINT | OP_WITHDRAW | OP_REDEEM | OP_TRANSFER | OP_SKIM | OP_REPAY | OP_REPAY_WITH_SHARES | OP_CONVERT_FEES | OP_FLASHLOAN | OP_TOUCH | OP_VAULT_STATUS_CHECK;
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; import {IFactory} from "../../BaseFactory/interfaces/IFactory.sol"; /// @title IEulerRouterFactory /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A minimal factory for EulerRouter. interface IEulerRouterFactory is IFactory { /// @notice Deploys a new EulerRouter. /// @param governor The governor of the router. /// @return The deployment address. function deploy(address governor) external returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; import {IFactory} from "../../BaseFactory/interfaces/IFactory.sol"; /// @title IEulerKinkIRMFactory /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A minimal factory for EulerKinkIRM. interface IEulerKinkIRMFactory is IFactory { /// @notice Deploys a new EulerKinkIRM. /// @param baseRate The base rate of the IRM. /// @param slope1 The slope of the IRM at the first kink. /// @param slope2 The slope of the IRM at the second kink. /// @param kink The kink of the IRM. /// @return The deployment address. function deploy(uint256 baseRate, uint256 slope1, uint256 slope2, uint256 kink) external returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {Context} from "openzeppelin-contracts/utils/Context.sol"; import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; import {EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol"; /// @title SnapshotRegistry /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Revokeable append-only registry of addresses. contract SnapshotRegistry is EVCUtil, Ownable { struct Entry { /// @notice The timestamp when the address was added. uint128 addedAt; /// @notice The timestamp when the address was revoked. uint128 revokedAt; } /// @notice List of addresses by their base and quote asset. /// @dev The keys are lexicographically sorted (asset0 < asset1). mapping(address asset0 => mapping(address asset1 => address[])) internal map; /// @notice Addresses added to the registry. mapping(address => Entry) public entries; /// @notice An address was added to the registry. /// @param element The address added. /// @param asset0 The smaller address out of (base, quote). /// @param asset1 The larger address out of (base, quote). /// @param addedAt The timestamp when the address was added. event Added(address indexed element, address indexed asset0, address indexed asset1, uint256 addedAt); /// @notice An address was revoked from the registry. /// @param element The address revoked. /// @param revokedAt The timestamp when the address was revoked. event Revoked(address indexed element, uint256 revokedAt); /// @notice The address cannot be added because it already exists in the registry. error Registry_AlreadyAdded(); /// @notice The address cannot be revoked because it does not exist in the registry. error Registry_NotAdded(); /// @notice The address cannot be revoked because it was already revoked from the registry. error Registry_AlreadyRevoked(); /// @notice Deploy SnapshotRegistry. /// @param _evc The address of the EVC. /// @param _owner The address of the owner. constructor(address _evc, address _owner) EVCUtil(_evc) Ownable(_owner) {} /// @notice Adds an address to the registry. /// @param element The address to add. /// @param base The corresponding base asset. /// @param quote The corresponding quote asset. /// @dev Only callable by the owner. function add(address element, address base, address quote) external onlyEVCAccountOwner onlyOwner { Entry storage entry = entries[element]; if (entry.addedAt != 0) revert Registry_AlreadyAdded(); entry.addedAt = uint128(block.timestamp); (address asset0, address asset1) = _sort(base, quote); map[asset0][asset1].push(element); emit Added(element, asset0, asset1, block.timestamp); } /// @notice Revokes an address from the registry. /// @param element The address to revoke. /// @dev Only callable by the owner. function revoke(address element) external onlyEVCAccountOwner onlyOwner { Entry storage entry = entries[element]; if (entry.addedAt == 0) revert Registry_NotAdded(); if (entry.revokedAt != 0) revert Registry_AlreadyRevoked(); entry.revokedAt = uint128(block.timestamp); emit Revoked(element, block.timestamp); } /// @notice Returns the all valid addresses for a given base and quote. /// @param base The address of the base asset. /// @param quote The address of the quote asset. /// @param snapshotTime The timestamp to check. /// @dev Order of base and quote does not matter. /// @return All addresses for base and quote valid at `snapshotTime`. function getValidAddresses(address base, address quote, uint256 snapshotTime) external view returns (address[] memory) { (address asset0, address asset1) = _sort(base, quote); address[] memory elements = map[asset0][asset1]; address[] memory validElements = new address[](elements.length); uint256 numValid = 0; for (uint256 i = 0; i < elements.length; ++i) { address element = elements[i]; if (isValid(element, snapshotTime)) { validElements[numValid++] = element; } } /// @solidity memory-safe-assembly assembly { // update the length mstore(validElements, numValid) } return validElements; } /// @notice Returns whether an address was valid at a point in time. /// @param element The address to check. /// @param snapshotTime The timestamp to check. /// @dev Returns false if: /// - address was never added, /// - address was added after the timestamp, /// - address was revoked before or at the timestamp. /// @return Whether `element` was valid at `snapshotTime`. function isValid(address element, uint256 snapshotTime) public view returns (bool) { uint256 addedAt = entries[element].addedAt; uint256 revokedAt = entries[element].revokedAt; if (addedAt == 0 || addedAt > snapshotTime) return false; if (revokedAt != 0 && revokedAt <= snapshotTime) return false; return true; } /// @notice Lexicographically sort two addresses. /// @param assetA One of the assets in the pair. /// @param assetB The other asset in the pair. /// @return The address first in lexicographic order. /// @return The address second in lexicographic order. function _sort(address assetA, address assetB) internal pure returns (address, address) { return assetA < assetB ? (assetA, assetB) : (assetB, assetA); } /// @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 override onlyEVCAccountOwner { super.renounceOwnership(); } /// @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 override onlyEVCAccountOwner { super.transferOwnership(newOwner); } /// @notice Retrieves the message sender in the context of the EVC. /// @dev This function returns the account on behalf of which the current operation is being performed, which is /// either msg.sender or the account authenticated by the EVC. /// @return The address of the message sender. function _msgSender() internal view override (Context, EVCUtil) returns (address) { return EVCUtil._msgSender(); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.24; import {EnumerableSet} from "openzeppelin-contracts/utils/structs/EnumerableSet.sol"; import {GenericFactory} from "evk/GenericFactory/GenericFactory.sol"; import {IPerspective} from "./interfaces/IPerspective.sol"; import {PerspectiveErrors} from "./PerspectiveErrors.sol"; /// @title BasePerspective /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A base contract for implementing a perspective. abstract contract BasePerspective is IPerspective, PerspectiveErrors { using EnumerableSet for EnumerableSet.AddressSet; struct Transient { uint256 placeholder; } GenericFactory public immutable vaultFactory; EnumerableSet.AddressSet internal verified; Transient private transientVerified; Transient private transientErrors; Transient private transientVault; Transient private transientFailEarly; /// @notice Creates a new BasePerspective instance. /// @param vaultFactory_ The address of the GenericFactory contract. constructor(address vaultFactory_) { vaultFactory = GenericFactory(vaultFactory_); } /// @inheritdoc IPerspective function name() public view virtual returns (string memory); /// @inheritdoc IPerspective function perspectiveVerify(address vault, bool failEarly) public virtual { bytes32 transientVerifiedHash; assembly { mstore(0, vault) mstore(32, transientVerified.slot) transientVerifiedHash := keccak256(0, 64) // if optimistically verified, return if eq(tload(transientVerifiedHash), true) { return(0, 0) } } // if already verified, return if (verified.contains(vault)) return; address _vault; bool _failEarly; assembly { _vault := tload(transientVault.slot) _failEarly := tload(transientFailEarly.slot) tstore(transientVault.slot, vault) tstore(transientFailEarly.slot, failEarly) // optimistically assume that the vault is verified tstore(transientVerifiedHash, true) } // perform the perspective verification perspectiveVerifyInternal(vault); uint256 errors; assembly { // restore the cached values tstore(transientVault.slot, _vault) tstore(transientFailEarly.slot, _failEarly) errors := tload(transientErrors.slot) } // if early fail was not requested, we need to check for any property errors that may have occurred. // otherwise, we would have already reverted if there were any property errors if (errors != 0) revert PerspectiveError(address(this), vault, errors); // set the vault as permanently verified verified.add(vault); emit PerspectiveVerified(vault); } /// @inheritdoc IPerspective function isVerified(address vault) public view virtual returns (bool) { return verified.contains(vault); } /// @inheritdoc IPerspective function verifiedLength() public view virtual returns (uint256) { return verified.length(); } /// @inheritdoc IPerspective function verifiedArray() public view virtual returns (address[] memory) { return verified.values(); } /// @notice Internal function to perform verification of a vault. /// @dev This function must be defined in derived contracts to implement specific verification logic. /// @dev This function should use the testProperty function to test the properties of the vault. /// @param vault The address of the vault to verify. function perspectiveVerifyInternal(address vault) internal virtual; /// @notice Tests a property condition and handles error based on the result. /// @param condition The boolean condition to test, typically a property of a vault. i.e governor == address(0) /// @param errorCode The error code to use if the condition fails. function testProperty(bool condition, uint256 errorCode) internal virtual { if (condition) return; if (errorCode == 0) revert PerspectivePanic(); bool failEarly; assembly { failEarly := tload(transientFailEarly.slot) } if (failEarly) { address vault; assembly { vault := tload(transientVault.slot) } revert PerspectiveError(address(this), vault, errorCode); } else { assembly { let errors := tload(transientErrors.slot) tstore(transientErrors.slot, or(errors, errorCode)) } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2; /// @dev Interface of the ERC20 standard as defined in the EIP. /// @dev This includes the optional name, symbol, and decimals metadata. interface IERC20 { /// @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`). event Transfer(address indexed from, address indexed to, uint256 value); /// @dev Emitted when the allowance of a `spender` for an `owner` is set, where `value` /// is the new allowance. event Approval(address indexed owner, address indexed spender, uint256 value); /// @notice Returns the amount of tokens in existence. function totalSupply() external view returns (uint256); /// @notice Returns the amount of tokens owned by `account`. function balanceOf(address account) external view returns (uint256); /// @notice Moves `amount` tokens from the caller's account to `to`. function transfer(address to, uint256 amount) external returns (bool); /// @notice Returns the remaining number of tokens that `spender` is allowed /// to spend on behalf of `owner` function allowance(address owner, address spender) external view returns (uint256); /// @notice Sets `amount` as the allowance of `spender` over the caller's tokens. /// @dev Be aware of front-running risks: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 function approve(address spender, uint256 amount) external returns (bool); /// @notice Moves `amount` tokens from `from` to `to` using the allowance mechanism. /// `amount` is then deducted from the caller's allowance. function transferFrom(address from, address to, uint256 amount) external returns (bool); /// @notice Returns the name of the token. function name() external view returns (string memory); /// @notice Returns the symbol of the token. function symbol() external view returns (string memory); /// @notice Returns the decimals places of the token. function decimals() external view returns (uint8); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; /// @title IPriceOracle /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Common PriceOracle interface. interface IPriceOracle { /// @notice Get the name of the oracle. /// @return The name of the oracle. function name() external view returns (string memory); /// @notice One-sided price: How much quote token you would get for inAmount of base token, assuming no price spread. /// @param inAmount The amount of `base` to convert. /// @param base The token that is being priced. /// @param quote The token that is the unit of account. /// @return outAmount The amount of `quote` that is equivalent to `inAmount` of `base`. function getQuote(uint256 inAmount, address base, address quote) external view returns (uint256 outAmount); /// @notice Two-sided price: How much quote token you would get/spend for selling/buying inAmount of base token. /// @param inAmount The amount of `base` to convert. /// @param base The token that is being priced. /// @param quote The token that is the unit of account. /// @return bidOutAmount The amount of `quote` you would get for selling `inAmount` of `base`. /// @return askOutAmount The amount of `quote` you would spend for buying `inAmount` of `base`. function getQuotes(uint256 inAmount, address base, address quote) external view returns (uint256 bidOutAmount, uint256 askOutAmount); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title Errors /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Collects common errors in PriceOracles. library Errors { /// @notice The external feed returned an invalid answer. error PriceOracle_InvalidAnswer(); /// @notice The configuration parameters for the PriceOracle are invalid. error PriceOracle_InvalidConfiguration(); /// @notice The base/quote path is not supported. /// @param base The address of the base asset. /// @param quote The address of the quote asset. error PriceOracle_NotSupported(address base, address quote); /// @notice The quote cannot be completed due to overflow. error PriceOracle_Overflow(); /// @notice The price is too stale. /// @param staleness The time elapsed since the price was updated. /// @param maxStaleness The maximum time elapsed since the last price update. error PriceOracle_TooStale(uint256 staleness, uint256 maxStaleness); /// @notice The method can only be called by the governor. error Governance_CallerNotGovernor(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import {EVCUtil} from "ethereum-vault-connector/utils/EVCUtil.sol"; import {Errors} from "./Errors.sol"; /// @title Governable /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Contract mixin for governance, compatible with EVC. abstract contract Governable is EVCUtil { /// @notice The active governor address. If `address(0)` then the role is renounced. address public governor; /// @notice Set the governor of the contract. /// @param oldGovernor The address of the previous governor. /// @param newGovernor The address of the newly appointed governor. event GovernorSet(address indexed oldGovernor, address indexed newGovernor); constructor(address _evc, address _governor) EVCUtil(_evc) { _setGovernor(_governor); } /// @notice Transfer the governor role to another address. /// @param newGovernor The address of the next governor. /// @dev Can only be called by the current governor. function transferGovernance(address newGovernor) external onlyEVCAccountOwner onlyGovernor { _setGovernor(newGovernor); } /// @notice Restrict access to the governor. /// @dev Consider also adding `onlyEVCAccountOwner` for stricter caller checks. modifier onlyGovernor() { if (_msgSender() != governor) { revert Errors.Governance_CallerNotGovernor(); } _; } /// @notice Set the governor address. /// @param newGovernor The address of the new governor. function _setGovernor(address newGovernor) internal { emit GovernorSet(governor, newGovernor); governor = newGovernor; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title BeaconProxy /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A proxy contract, forwarding all calls to an implementation contract, fetched from a beacon /// @dev The proxy attaches up to 128 bytes of metadata to the delegated call data. contract BeaconProxy { // ERC-1967 beacon address slot. bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1) bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; // Beacon implementation() selector bytes32 internal constant IMPLEMENTATION_SELECTOR = 0x5c60da1b00000000000000000000000000000000000000000000000000000000; // Max trailing data length, 4 immutable slots uint256 internal constant MAX_TRAILING_DATA_LENGTH = 128; address internal immutable beacon; uint256 internal immutable metadataLength; bytes32 internal immutable metadata0; bytes32 internal immutable metadata1; bytes32 internal immutable metadata2; bytes32 internal immutable metadata3; event Genesis(); constructor(bytes memory trailingData) { emit Genesis(); require(trailingData.length <= MAX_TRAILING_DATA_LENGTH, "trailing data too long"); // Beacon is always the proxy creator; store it in immutable beacon = msg.sender; // Store the beacon address in ERC-1967 slot for compatibility with block explorers assembly { sstore(BEACON_SLOT, caller()) } // Record length as immutable metadataLength = trailingData.length; // Pad length with uninitialized memory so the decode will succeed assembly { mstore(trailingData, MAX_TRAILING_DATA_LENGTH) } (metadata0, metadata1, metadata2, metadata3) = abi.decode(trailingData, (bytes32, bytes32, bytes32, bytes32)); } fallback() external payable { address beacon_ = beacon; uint256 metadataLength_ = metadataLength; bytes32 metadata0_ = metadata0; bytes32 metadata1_ = metadata1; bytes32 metadata2_ = metadata2; bytes32 metadata3_ = metadata3; assembly { // Fetch implementation address from the beacon mstore(0, IMPLEMENTATION_SELECTOR) // Implementation call is trusted not to revert and to return an address let result := staticcall(gas(), beacon_, 0, 4, 0, 32) let implementation := mload(0) // delegatecall to the implementation with trailing metadata calldatacopy(0, 0, calldatasize()) mstore(calldatasize(), metadata0_) mstore(add(32, calldatasize()), metadata1_) mstore(add(64, calldatasize()), metadata2_) mstore(add(96, calldatasize()), metadata3_) result := delegatecall(gas(), implementation, 0, add(metadataLength_, calldatasize()), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title MetaProxyDeployer /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice Contract for deploying minimal proxies with metadata, based on EIP-3448. /// @dev The metadata of the proxies does not include the data length as defined by EIP-3448, saving gas at a cost of /// supporting variable size data. contract MetaProxyDeployer { error E_DeploymentFailed(); // Meta proxy bytecode from EIP-3488 https://eips.ethereum.org/EIPS/eip-3448 bytes constant BYTECODE_HEAD = hex"600b380380600b3d393df3363d3d373d3d3d3d60368038038091363936013d73"; bytes constant BYTECODE_TAIL = hex"5af43d3d93803e603457fd5bf3"; /// @dev Creates a proxy for `targetContract` with metadata from `metadata`. /// @return addr A non-zero address if successful. function deployMetaProxy(address targetContract, bytes memory metadata) internal returns (address addr) { bytes memory code = abi.encodePacked(BYTECODE_HEAD, targetContract, BYTECODE_TAIL, metadata); assembly ("memory-safe") { addr := create(0, add(code, 32), mload(code)) } if (addr == address(0)) revert E_DeploymentFailed(); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; /// @title IVault /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice This interface defines the methods for the Vault for the purpose of integration with the Ethereum Vault /// Connector. interface IVault { /// @notice Disables a controller (this vault) for the authenticated account. /// @dev A controller is a vault that has been chosen for an account to have special control over account’s /// balances in the enabled collaterals vaults. User calls this function in order for the vault to disable itself /// for the account if the conditions are met (i.e. user has repaid debt in full). If the conditions are not met, /// the function reverts. function disableController() external; /// @notice Checks the status of an account. /// @dev This function must only deliberately revert if the account status is invalid. If this function reverts due /// to any other reason, it may render the account unusable with possibly no way to recover funds. /// @param account The address of the account to be checked. /// @param collaterals The array of enabled collateral addresses to be considered for the account status check. /// @return magicValue Must return the bytes4 magic value 0xb168c58f (which is a selector of this function) when /// account status is valid, or revert otherwise. function checkAccountStatus( address account, address[] calldata collaterals ) external view returns (bytes4 magicValue); /// @notice Checks the status of the vault. /// @dev This function must only deliberately revert if the vault status is invalid. If this function reverts due to /// any other reason, it may render some accounts unusable with possibly no way to recover funds. /// @return magicValue Must return the bytes4 magic value 0x4b3d1223 (which is a selector of this function) when /// account status is valid, or revert otherwise. function checkVaultStatus() external returns (bytes4 magicValue); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; /// @title IFactory /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A minimal factory interface for deploying contracts. interface IFactory { struct DeploymentInfo { /// @notice The sender of the deployment call. address deployer; /// @notice The timestamp when the contract was deployed. uint96 deployedAt; } /// @notice An instance of a contract was deployed. /// @param deployedContract The deployment address of the contract. /// @param deployer The sender of the deployment call. /// @param deployedAt The deployment timestamp of the contract. event ContractDeployed(address indexed deployedContract, address indexed deployer, uint256 deployedAt); /// @notice Error thrown when the query is incorrect. error Factory_BadQuery(); /// @notice Contracts deployed by the factory. function getDeploymentInfo(address contractAddress) external view returns (address deployer, uint96 deployedAt); /// @notice Checks if the deployment at the given address is valid. /// @param contractAddress The address of the contract to check. /// @return True if the deployment is valid, false otherwise. function isValidDeployment(address contractAddress) external view returns (bool); /// @notice Returns the number of contracts deployed by the factory. /// @return The number of deployed contracts. function getDeploymentsListLength() external view returns (uint256); /// @notice Returns a slice of the list of deployments. /// @param start The starting index of the slice. /// @param end The ending index of the slice (exclusive). /// @return list An array of addresses of the deployed contracts in the specified range. function getDeploymentsListSlice(uint256 start, uint256 end) external view returns (address[] memory list); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IEVC} from "../interfaces/IEthereumVaultConnector.sol"; import {ExecutionContext, EC} from "../ExecutionContext.sol"; /// @title EVCUtil /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice This contract is an abstract base contract for interacting with the Ethereum Vault Connector (EVC). /// It provides utility functions for authenticating the callers in the context of the EVC, a pattern for enforcing the /// contracts to be called through the EVC. abstract contract EVCUtil { using ExecutionContext for EC; uint160 internal constant ACCOUNT_ID_OFFSET = 8; IEVC internal immutable evc; error EVC_InvalidAddress(); error NotAuthorized(); error ControllerDisabled(); constructor(address _evc) { if (_evc == address(0)) revert EVC_InvalidAddress(); evc = IEVC(_evc); } /// @notice Returns the address of the Ethereum Vault Connector (EVC) used by this contract. /// @return The address of the EVC contract. function EVC() external view virtual returns (address) { return address(evc); } /// @notice Ensures that the msg.sender is the EVC by using the EVC callback functionality if necessary. /// @dev Optional to use for functions requiring account and vault status checks to enforce predictable behavior. /// @dev If this modifier used in conjuction with any other modifier, it must appear as the first (outermost) /// modifier of the function. modifier callThroughEVC() virtual { _callThroughEVC(); _; } /// @notice Ensures that the caller is the EVC in the appropriate context. /// @dev Should be used for checkAccountStatus and checkVaultStatus functions. modifier onlyEVCWithChecksInProgress() virtual { _onlyEVCWithChecksInProgress(); _; } /// @notice Ensures a standard authentication path on the EVC allowing the account owner or any of its EVC accounts. /// @dev This modifier checks if the caller is the EVC and if so, verifies the execution context. /// It reverts if the operator is authenticated, control collateral is in progress, or checks are in progress. /// @dev This modifier must not be used on functions utilized by liquidation flows, i.e. transfer or withdraw. /// @dev This modifier must not be used on checkAccountStatus and checkVaultStatus functions. /// @dev This modifier can be used on access controlled functions to prevent non-standard authentication paths on /// the EVC. modifier onlyEVCAccount() virtual { _authenticateCallerWithStandardContextState(false); _; } /// @notice Ensures a standard authentication path on the EVC. /// @dev This modifier checks if the caller is the EVC and if so, verifies the execution context. /// It reverts if the operator is authenticated, control collateral is in progress, or checks are in progress. /// It reverts if the authenticated account owner is known and it is not the account owner. /// @dev It assumes that if the caller is not the EVC, the caller is the account owner. /// @dev This modifier must not be used on functions utilized by liquidation flows, i.e. transfer or withdraw. /// @dev This modifier must not be used on checkAccountStatus and checkVaultStatus functions. /// @dev This modifier can be used on access controlled functions to prevent non-standard authentication paths on /// the EVC. modifier onlyEVCAccountOwner() virtual { _authenticateCallerWithStandardContextState(true); _; } /// @notice Checks whether the specified account and the other account have the same owner. /// @dev The function is used to check whether one account is authorized to perform operations on behalf of the /// other. Accounts are considered to have a common owner if they share the first 19 bytes of their address. /// @param account The address of the account that is being checked. /// @param otherAccount The address of the other account that is being checked. /// @return A boolean flag that indicates whether the accounts have the same owner. function _haveCommonOwner(address account, address otherAccount) internal pure returns (bool) { bool result; assembly { result := lt(xor(account, otherAccount), 0x100) } return result; } /// @notice Returns the address prefix of the specified account. /// @dev The address prefix is the first 19 bytes of the account address. /// @param account The address of the account whose address prefix is being retrieved. /// @return A bytes19 value that represents the address prefix of the account. function _getAddressPrefix(address account) internal pure returns (bytes19) { return bytes19(uint152(uint160(account) >> ACCOUNT_ID_OFFSET)); } /// @notice Retrieves the message sender in the context of the EVC. /// @dev This function returns the account on behalf of which the current operation is being performed, which is /// either msg.sender or the account authenticated by the EVC. /// @return The address of the message sender. function _msgSender() internal view virtual returns (address) { address sender = msg.sender; if (sender == address(evc)) { (sender,) = evc.getCurrentOnBehalfOfAccount(address(0)); } return sender; } /// @notice Retrieves the message sender in the context of the EVC for a borrow operation. /// @dev This function returns the account on behalf of which the current operation is being performed, which is /// either msg.sender or the account authenticated by the EVC. This function reverts if this contract is not enabled /// as a controller for the account on behalf of which the operation is being executed. /// @return The address of the message sender. function _msgSenderForBorrow() internal view virtual returns (address) { address sender = msg.sender; bool controllerEnabled; if (sender == address(evc)) { (sender, controllerEnabled) = evc.getCurrentOnBehalfOfAccount(address(this)); } else { controllerEnabled = evc.isControllerEnabled(sender, address(this)); } if (!controllerEnabled) { revert ControllerDisabled(); } return sender; } /// @notice Retrieves the message sender, ensuring it's any EVC account meaning that the execution context is in a /// standard state (not operator authenticated, not control collateral in progress, not checks in progress). /// @dev This function must not be used on functions utilized by liquidation flows, i.e. transfer or withdraw. /// @dev This function must not be used on checkAccountStatus and checkVaultStatus functions. /// @dev This function can be used on access controlled functions to prevent non-standard authentication paths on /// the EVC. /// @return The address of the message sender. function _msgSenderOnlyEVCAccount() internal view returns (address) { return _authenticateCallerWithStandardContextState(false); } /// @notice Retrieves the message sender, ensuring it's the EVC account owner and that the execution context is in a /// standard state (not operator authenticated, not control collateral in progress, not checks in progress). /// @dev It assumes that if the caller is not the EVC, the caller is the account owner. /// @dev This function must not be used on functions utilized by liquidation flows, i.e. transfer or withdraw. /// @dev This function must not be used on checkAccountStatus and checkVaultStatus functions. /// @dev This function can be used on access controlled functions to prevent non-standard authentication paths on /// the EVC. /// @return The address of the message sender. function _msgSenderOnlyEVCAccountOwner() internal view returns (address) { return _authenticateCallerWithStandardContextState(true); } /// @notice Calls the current external function through the EVC. /// @dev This function is used to route the current call through the EVC if it's not already coming from the EVC. It /// makes the EVC set the execution context and call back this contract with unchanged calldata. msg.sender is used /// as the onBehalfOfAccount. /// @dev This function shall only be used by the callThroughEVC modifier. function _callThroughEVC() internal { address _evc = address(evc); if (msg.sender == _evc) return; assembly { mstore(0, 0x1f8b521500000000000000000000000000000000000000000000000000000000) // EVC.call selector mstore(4, address()) // EVC.call 1st argument - address(this) mstore(36, caller()) // EVC.call 2nd argument - msg.sender mstore(68, callvalue()) // EVC.call 3rd argument - msg.value mstore(100, 128) // EVC.call 4th argument - msg.data, offset to the start of encoding - 128 bytes mstore(132, calldatasize()) // msg.data length calldatacopy(164, 0, calldatasize()) // original calldata // abi encoded bytes array should be zero padded so its length is a multiple of 32 // store zero word after msg.data bytes and round up calldatasize to nearest multiple of 32 mstore(add(164, calldatasize()), 0) let result := call(gas(), _evc, callvalue(), 0, add(164, and(add(calldatasize(), 31), not(31))), 0, 0) returndatacopy(0, 0, returndatasize()) switch result case 0 { revert(0, returndatasize()) } default { return(64, sub(returndatasize(), 64)) } // strip bytes encoding from call return } } /// @notice Ensures that the function is called only by the EVC during the checks phase /// @dev Reverts if the caller is not the EVC or if checks are not in progress. function _onlyEVCWithChecksInProgress() internal view { if (msg.sender != address(evc) || !evc.areChecksInProgress()) { revert NotAuthorized(); } } /// @notice Ensures that the function is called only by the EVC account owner or any of its EVC accounts /// @dev This function checks if the caller is the EVC and if so, verifies that the execution context is not in a /// special state (operator authenticated, collateral control in progress, or checks in progress). If /// onlyAccountOwner is true and the owner was already registered on the EVC, it verifies that the onBehalfOfAccount /// is the owner. If onlyAccountOwner is false, it allows any EVC account of the owner to call the function. /// @param onlyAccountOwner If true, only allows the account owner; if false, allows any EVC account of the owner /// @return The address of the message sender. function _authenticateCallerWithStandardContextState(bool onlyAccountOwner) internal view returns (address) { if (msg.sender == address(evc)) { EC ec = EC.wrap(evc.getRawExecutionContext()); if (ec.isOperatorAuthenticated() || ec.isControlCollateralInProgress() || ec.areChecksInProgress()) { revert NotAuthorized(); } address onBehalfOfAccount = ec.getOnBehalfOfAccount(); if (onlyAccountOwner) { address owner = evc.getAccountOwner(onBehalfOfAccount); if (owner != address(0) && owner != onBehalfOfAccount) { revert NotAuthorized(); } } return onBehalfOfAccount; } return msg.sender; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; /// @title IPerspective /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A contract that verifies the properties of a vault. interface IPerspective { /// @notice Emitted when a vault is verified successfully. /// @param vault The address of the vault that has been verified. event PerspectiveVerified(address indexed vault); /// @notice Error thrown when a perspective verification fails. /// @param perspective The address of the perspective contract where the error occurred. /// @param vault The address of the vault being verified. /// @param codes The error codes indicating the reasons for verification failure. error PerspectiveError(address perspective, address vault, uint256 codes); /// @notice Error thrown when a panic occurs in the perspective contract. error PerspectivePanic(); /// @notice Returns the name of the perspective. /// @dev Name should be unique and descriptive. /// @return The name of the perspective. function name() external view returns (string memory); /// @notice Verifies the properties of a vault. /// @param vault The address of the vault to verify. /// @param failEarly Determines whether to fail early on the first error encountered or allow the verification to /// continue and report all errors. function perspectiveVerify(address vault, bool failEarly) external; /// @notice Checks if a vault is verified. /// @param vault The address of the vault to check. /// @return True if the vault is verified, false otherwise. function isVerified(address vault) external view returns (bool); /// @notice Returns the number of verified vaults. /// @return The number of verified vaults. function verifiedLength() external view returns (uint256); /// @notice Returns an array of all verified vault addresses. /// @return An array of addresses of verified vaults. function verifiedArray() external view returns (address[] memory); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; /// @title PerspectiveErrors /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice A contract that defines the error codes for the perspectives. abstract contract PerspectiveErrors { uint256 internal constant ERROR__FACTORY = 1 << 0; uint256 internal constant ERROR__IMPLEMENTATION = 1 << 1; uint256 internal constant ERROR__UPGRADABILITY = 1 << 2; uint256 internal constant ERROR__SINGLETON = 1 << 3; uint256 internal constant ERROR__NESTING = 1 << 4; uint256 internal constant ERROR__ORACLE_INVALID_ROUTER = 1 << 5; uint256 internal constant ERROR__ORACLE_GOVERNED_ROUTER = 1 << 6; uint256 internal constant ERROR__ORACLE_INVALID_FALLBACK = 1 << 7; uint256 internal constant ERROR__ORACLE_INVALID_ROUTER_CONFIG = 1 << 8; uint256 internal constant ERROR__ORACLE_INVALID_ADAPTER = 1 << 9; uint256 internal constant ERROR__UNIT_OF_ACCOUNT = 1 << 10; uint256 internal constant ERROR__CREATOR = 1 << 11; uint256 internal constant ERROR__GOVERNOR = 1 << 12; uint256 internal constant ERROR__FEE_RECEIVER = 1 << 13; uint256 internal constant ERROR__INTEREST_FEE = 1 << 14; uint256 internal constant ERROR__INTEREST_RATE_MODEL = 1 << 15; uint256 internal constant ERROR__SUPPLY_CAP = 1 << 16; uint256 internal constant ERROR__BORROW_CAP = 1 << 17; uint256 internal constant ERROR__HOOK_TARGET = 1 << 18; uint256 internal constant ERROR__HOOKED_OPS = 1 << 19; uint256 internal constant ERROR__CONFIG_FLAGS = 1 << 20; uint256 internal constant ERROR__NAME = 1 << 21; uint256 internal constant ERROR__SYMBOL = 1 << 22; uint256 internal constant ERROR__LIQUIDATION_DISCOUNT = 1 << 23; uint256 internal constant ERROR__LIQUIDATION_COOL_OFF_TIME = 1 << 24; uint256 internal constant ERROR__LTV_COLLATERAL_CONFIG_LENGTH = 1 << 25; uint256 internal constant ERROR__LTV_COLLATERAL_CONFIG_SEPARATION = 1 << 26; uint256 internal constant ERROR__LTV_COLLATERAL_CONFIG_BORROW = 1 << 27; uint256 internal constant ERROR__LTV_COLLATERAL_CONFIG_LIQUIDATION = 1 << 28; uint256 internal constant ERROR__LTV_COLLATERAL_RAMPING = 1 << 29; uint256 internal constant ERROR__LTV_COLLATERAL_RECOGNITION = 1 << 30; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.8.0; /// @title IEVC /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice This interface defines the methods for the Ethereum Vault Connector. interface IEVC { /// @notice A struct representing a batch item. /// @dev Each batch item represents a single operation to be performed within a checks deferred context. struct BatchItem { /// @notice The target contract to be called. address targetContract; /// @notice The account on behalf of which the operation is to be performed. msg.sender must be authorized to /// act on behalf of this account. Must be address(0) if the target contract is the EVC itself. address onBehalfOfAccount; /// @notice The amount of value to be forwarded with the call. If the value is type(uint256).max, the whole /// balance of the EVC contract will be forwarded. Must be 0 if the target contract is the EVC itself. uint256 value; /// @notice The encoded data which is called on the target contract. bytes data; } /// @notice A struct representing the result of a batch item operation. /// @dev Used only for simulation purposes. struct BatchItemResult { /// @notice A boolean indicating whether the operation was successful. bool success; /// @notice The result of the operation. bytes result; } /// @notice A struct representing the result of the account or vault status check. /// @dev Used only for simulation purposes. struct StatusCheckResult { /// @notice The address of the account or vault for which the check was performed. address checkedAddress; /// @notice A boolean indicating whether the status of the account or vault is valid. bool isValid; /// @notice The result of the check. bytes result; } /// @notice Returns current raw execution context. /// @dev When checks in progress, on behalf of account is always address(0). /// @return context Current raw execution context. function getRawExecutionContext() external view returns (uint256 context); /// @notice Returns an account on behalf of which the operation is being executed at the moment and whether the /// controllerToCheck is an enabled controller for that account. /// @dev This function should only be used by external smart contracts if msg.sender is the EVC. Otherwise, the /// account address returned must not be trusted. /// @dev When checks in progress, on behalf of account is always address(0). When address is zero, the function /// reverts to protect the consumer from ever relying on the on behalf of account address which is in its default /// state. /// @param controllerToCheck The address of the controller for which it is checked whether it is an enabled /// controller for the account on behalf of which the operation is being executed at the moment. /// @return onBehalfOfAccount An account that has been authenticated and on behalf of which the operation is being /// executed at the moment. /// @return controllerEnabled A boolean value that indicates whether controllerToCheck is an enabled controller for /// the account on behalf of which the operation is being executed at the moment. Always false if controllerToCheck /// is address(0). function getCurrentOnBehalfOfAccount(address controllerToCheck) external view returns (address onBehalfOfAccount, bool controllerEnabled); /// @notice Checks if checks are deferred. /// @return A boolean indicating whether checks are deferred. function areChecksDeferred() external view returns (bool); /// @notice Checks if checks are in progress. /// @return A boolean indicating whether checks are in progress. function areChecksInProgress() external view returns (bool); /// @notice Checks if control collateral is in progress. /// @return A boolean indicating whether control collateral is in progress. function isControlCollateralInProgress() external view returns (bool); /// @notice Checks if an operator is authenticated. /// @return A boolean indicating whether an operator is authenticated. function isOperatorAuthenticated() external view returns (bool); /// @notice Checks if a simulation is in progress. /// @return A boolean indicating whether a simulation is in progress. function isSimulationInProgress() external view returns (bool); /// @notice Checks whether the specified account and the other account have the same owner. /// @dev The function is used to check whether one account is authorized to perform operations on behalf of the /// other. Accounts are considered to have a common owner if they share the first 19 bytes of their address. /// @param account The address of the account that is being checked. /// @param otherAccount The address of the other account that is being checked. /// @return A boolean flag that indicates whether the accounts have the same owner. function haveCommonOwner(address account, address otherAccount) external pure returns (bool); /// @notice Returns the address prefix of the specified account. /// @dev The address prefix is the first 19 bytes of the account address. /// @param account The address of the account whose address prefix is being retrieved. /// @return A bytes19 value that represents the address prefix of the account. function getAddressPrefix(address account) external pure returns (bytes19); /// @notice Returns the owner for the specified account. /// @dev The function returns address(0) if the owner is not registered. Registration of the owner happens on the /// initial /// interaction with the EVC that requires authentication of an owner. /// @param account The address of the account whose owner is being retrieved. /// @return owner The address of the account owner. An account owner is an EOA/smart contract which address matches /// the first 19 bytes of the account address. function getAccountOwner(address account) external view returns (address); /// @notice Checks if lockdown mode is enabled for a given address prefix. /// @param addressPrefix The address prefix to check for lockdown mode status. /// @return A boolean indicating whether lockdown mode is enabled. function isLockdownMode(bytes19 addressPrefix) external view returns (bool); /// @notice Checks if permit functionality is disabled for a given address prefix. /// @param addressPrefix The address prefix to check for permit functionality status. /// @return A boolean indicating whether permit functionality is disabled. function isPermitDisabledMode(bytes19 addressPrefix) external view returns (bool); /// @notice Returns the current nonce for a given address prefix and nonce namespace. /// @dev Each nonce namespace provides 256 bit nonce that has to be used sequentially. There's no requirement to use /// all the nonces for a given nonce namespace before moving to the next one which allows to use permit messages in /// a non-sequential manner. /// @param addressPrefix The address prefix for which the nonce is being retrieved. /// @param nonceNamespace The nonce namespace for which the nonce is being retrieved. /// @return nonce The current nonce for the given address prefix and nonce namespace. function getNonce(bytes19 addressPrefix, uint256 nonceNamespace) external view returns (uint256 nonce); /// @notice Returns the bit field for a given address prefix and operator. /// @dev The bit field is used to store information about authorized operators for a given address prefix. Each bit /// in the bit field corresponds to one account belonging to the same owner. If the bit is set, the operator is /// authorized for the account. /// @param addressPrefix The address prefix for which the bit field is being retrieved. /// @param operator The address of the operator for which the bit field is being retrieved. /// @return operatorBitField The bit field for the given address prefix and operator. The bit field defines which /// accounts the operator is authorized for. It is a 256-position binary array like 0...010...0, marking the account /// positionally in a uint256. The position in the bit field corresponds to the account ID (0-255), where 0 is the /// owner account's ID. function getOperator(bytes19 addressPrefix, address operator) external view returns (uint256 operatorBitField); /// @notice Returns whether a given operator has been authorized for a given account. /// @param account The address of the account whose operator is being checked. /// @param operator The address of the operator that is being checked. /// @return authorized A boolean value that indicates whether the operator is authorized for the account. function isAccountOperatorAuthorized(address account, address operator) external view returns (bool authorized); /// @notice Enables or disables lockdown mode for a given address prefix. /// @dev This function can only be called by the owner of the address prefix. To disable this mode, the EVC /// must be called directly. It is not possible to disable this mode by using checks-deferrable call or /// permit message. /// @param addressPrefix The address prefix for which the lockdown mode is being set. /// @param enabled A boolean indicating whether to enable or disable lockdown mode. function setLockdownMode(bytes19 addressPrefix, bool enabled) external payable; /// @notice Enables or disables permit functionality for a given address prefix. /// @dev This function can only be called by the owner of the address prefix. To disable this mode, the EVC /// must be called directly. It is not possible to disable this mode by using checks-deferrable call or (by /// definition) permit message. To support permit functionality by default, note that the logic was inverted here. To /// disable the permit functionality, one must pass true as the second argument. To enable the permit /// functionality, one must pass false as the second argument. /// @param addressPrefix The address prefix for which the permit functionality is being set. /// @param enabled A boolean indicating whether to enable or disable the disable-permit mode. function setPermitDisabledMode(bytes19 addressPrefix, bool enabled) external payable; /// @notice Sets the nonce for a given address prefix and nonce namespace. /// @dev This function can only be called by the owner of the address prefix. Each nonce namespace provides a 256 /// bit nonce that has to be used sequentially. There's no requirement to use all the nonces for a given nonce /// namespace before moving to the next one which allows the use of permit messages in a non-sequential manner. To /// invalidate signed permit messages, set the nonce for a given nonce namespace accordingly. To invalidate all the /// permit messages for a given nonce namespace, set the nonce to type(uint).max. /// @param addressPrefix The address prefix for which the nonce is being set. /// @param nonceNamespace The nonce namespace for which the nonce is being set. /// @param nonce The new nonce for the given address prefix and nonce namespace. function setNonce(bytes19 addressPrefix, uint256 nonceNamespace, uint256 nonce) external payable; /// @notice Sets the bit field for a given address prefix and operator. /// @dev This function can only be called by the owner of the address prefix. Each bit in the bit field corresponds /// to one account belonging to the same owner. If the bit is set, the operator is authorized for the account. /// @param addressPrefix The address prefix for which the bit field is being set. /// @param operator The address of the operator for which the bit field is being set. Can neither be the EVC address /// nor an address belonging to the same address prefix. /// @param operatorBitField The new bit field for the given address prefix and operator. Reverts if the provided /// value is equal to the currently stored value. function setOperator(bytes19 addressPrefix, address operator, uint256 operatorBitField) external payable; /// @notice Authorizes or deauthorizes an operator for the account. /// @dev Only the owner or authorized operator of the account can call this function. An operator is an address that /// can perform actions for an account on behalf of the owner. If it's an operator calling this function, it can /// only deauthorize itself. /// @param account The address of the account whose operator is being set or unset. /// @param operator The address of the operator that is being installed or uninstalled. Can neither be the EVC /// address nor an address belonging to the same owner as the account. /// @param authorized A boolean value that indicates whether the operator is being authorized or deauthorized. /// Reverts if the provided value is equal to the currently stored value. function setAccountOperator(address account, address operator, bool authorized) external payable; /// @notice Returns an array of collaterals enabled for an account. /// @dev A collateral is a vault for which an account's balances are under the control of the currently enabled /// controller vault. /// @param account The address of the account whose collaterals are being queried. /// @return An array of addresses that are enabled collaterals for the account. function getCollaterals(address account) external view returns (address[] memory); /// @notice Returns whether a collateral is enabled for an account. /// @dev A collateral is a vault for which account's balances are under the control of the currently enabled /// controller vault. /// @param account The address of the account that is being checked. /// @param vault The address of the collateral that is being checked. /// @return A boolean value that indicates whether the vault is an enabled collateral for the account or not. function isCollateralEnabled(address account, address vault) external view returns (bool); /// @notice Enables a collateral for an account. /// @dev A collaterals is a vault for which account's balances are under the control of the currently enabled /// controller vault. Only the owner or an operator of the account can call this function. Unless it's a duplicate, /// the collateral is added to the end of the array. There can be at most 10 unique collaterals enabled at a time. /// Account status checks are performed. /// @param account The account address for which the collateral is being enabled. /// @param vault The address being enabled as a collateral. function enableCollateral(address account, address vault) external payable; /// @notice Disables a collateral for an account. /// @dev This function does not preserve the order of collaterals in the array obtained using the getCollaterals /// function; the order may change. A collateral is a vault for which account’s balances are under the control of /// the currently enabled controller vault. Only the owner or an operator of the account can call this function. /// Disabling a collateral might change the order of collaterals in the array obtained using getCollaterals /// function. Account status checks are performed. /// @param account The account address for which the collateral is being disabled. /// @param vault The address of a collateral being disabled. function disableCollateral(address account, address vault) external payable; /// @notice Swaps the position of two collaterals so that they appear switched in the array of collaterals for a /// given account obtained by calling getCollaterals function. /// @dev A collateral is a vault for which account’s balances are under the control of the currently enabled /// controller vault. Only the owner or an operator of the account can call this function. The order of collaterals /// can be changed by specifying the indices of the two collaterals to be swapped. Indices are zero-based and must /// be in the range of 0 to the number of collaterals minus 1. index1 must be lower than index2. Account status /// checks are performed. /// @param account The address of the account for which the collaterals are being reordered. /// @param index1 The index of the first collateral to be swapped. /// @param index2 The index of the second collateral to be swapped. function reorderCollaterals(address account, uint8 index1, uint8 index2) external payable; /// @notice Returns an array of enabled controllers for an account. /// @dev A controller is a vault that has been chosen for an account to have special control over the account's /// balances in enabled collaterals vaults. A user can have multiple controllers during a call execution, but at /// most one can be selected when the account status check is performed. /// @param account The address of the account whose controllers are being queried. /// @return An array of addresses that are the enabled controllers for the account. function getControllers(address account) external view returns (address[] memory); /// @notice Returns whether a controller is enabled for an account. /// @dev A controller is a vault that has been chosen for an account to have special control over account’s /// balances in the enabled collaterals vaults. /// @param account The address of the account that is being checked. /// @param vault The address of the controller that is being checked. /// @return A boolean value that indicates whether the vault is enabled controller for the account or not. function isControllerEnabled(address account, address vault) external view returns (bool); /// @notice Enables a controller for an account. /// @dev A controller is a vault that has been chosen for an account to have special control over account’s /// balances in the enabled collaterals vaults. Only the owner or an operator of the account can call this function. /// Unless it's a duplicate, the controller is added to the end of the array. Transiently, there can be at most 10 /// unique controllers enabled at a time, but at most one can be enabled after the outermost checks-deferrable /// call concludes. Account status checks are performed. /// @param account The address for which the controller is being enabled. /// @param vault The address of the controller being enabled. function enableController(address account, address vault) external payable; /// @notice Disables a controller for an account. /// @dev A controller is a vault that has been chosen for an account to have special control over account’s /// balances in the enabled collaterals vaults. Only the vault itself can call this function. Disabling a controller /// might change the order of controllers in the array obtained using getControllers function. Account status checks /// are performed. /// @param account The address for which the calling controller is being disabled. function disableController(address account) external payable; /// @notice Executes signed arbitrary data by self-calling into the EVC. /// @dev Low-level call function is used to execute the arbitrary data signed by the owner or the operator on the /// EVC contract. During that call, EVC becomes msg.sender. /// @param signer The address signing the permit message (ECDSA) or verifying the permit message signature /// (ERC-1271). It's also the owner or the operator of all the accounts for which authentication will be needed /// during the execution of the arbitrary data call. /// @param sender The address of the msg.sender which is expected to execute the data signed by the signer. If /// address(0) is passed, the msg.sender is ignored. /// @param nonceNamespace The nonce namespace for which the nonce is being used. /// @param nonce The nonce for the given account and nonce namespace. A valid nonce value is considered to be the /// value currently stored and can take any value between 0 and type(uint256).max - 1. /// @param deadline The timestamp after which the permit is considered expired. /// @param value The amount of value to be forwarded with the call. If the value is type(uint256).max, the whole /// balance of the EVC contract will be forwarded. /// @param data The encoded data which is self-called on the EVC contract. /// @param signature The signature of the data signed by the signer. function permit( address signer, address sender, uint256 nonceNamespace, uint256 nonce, uint256 deadline, uint256 value, bytes calldata data, bytes calldata signature ) external payable; /// @notice Calls into a target contract as per data encoded. /// @dev This function defers the account and vault status checks (it's a checks-deferrable call). If the outermost /// call ends, the account and vault status checks are performed. /// @dev This function can be used to interact with any contract while checks are deferred. If the target contract /// is msg.sender, msg.sender is called back with the calldata provided and the context set up according to the /// account provided. If the target contract is not msg.sender, only the owner or the operator of the account /// provided can call this function. /// @dev This function can be used to recover the remaining value from the EVC contract. /// @param targetContract The address of the contract to be called. /// @param onBehalfOfAccount If the target contract is msg.sender, the address of the account which will be set /// in the context. It assumes msg.sender has authenticated the account themselves. If the target contract is /// not msg.sender, the address of the account for which it is checked whether msg.sender is authorized to act /// on behalf of. /// @param value The amount of value to be forwarded with the call. If the value is type(uint256).max, the whole /// balance of the EVC contract will be forwarded. /// @param data The encoded data which is called on the target contract. /// @return result The result of the call. function call( address targetContract, address onBehalfOfAccount, uint256 value, bytes calldata data ) external payable returns (bytes memory result); /// @notice For a given account, calls into one of the enabled collateral vaults from the currently enabled /// controller vault as per data encoded. /// @dev This function defers the account and vault status checks (it's a checks-deferrable call). If the outermost /// call ends, the account and vault status checks are performed. /// @dev This function can be used to interact with any contract while checks are deferred as long as the contract /// is enabled as a collateral of the account and the msg.sender is the only enabled controller of the account. /// @param targetCollateral The collateral address to be called. /// @param onBehalfOfAccount The address of the account for which it is checked whether msg.sender is authorized to /// act on behalf. /// @param value The amount of value to be forwarded with the call. If the value is type(uint256).max, the whole /// balance of the EVC contract will be forwarded. /// @param data The encoded data which is called on the target collateral. /// @return result The result of the call. function controlCollateral( address targetCollateral, address onBehalfOfAccount, uint256 value, bytes calldata data ) external payable returns (bytes memory result); /// @notice Executes multiple calls into the target contracts while checks deferred as per batch items provided. /// @dev This function defers the account and vault status checks (it's a checks-deferrable call). If the outermost /// call ends, the account and vault status checks are performed. /// @dev The authentication rules for each batch item are the same as for the call function. /// @param items An array of batch items to be executed. function batch(BatchItem[] calldata items) external payable; /// @notice Executes multiple calls into the target contracts while checks deferred as per batch items provided. /// @dev This function always reverts as it's only used for simulation purposes. This function cannot be called /// within a checks-deferrable call. /// @param items An array of batch items to be executed. function batchRevert(BatchItem[] calldata items) external payable; /// @notice Executes multiple calls into the target contracts while checks deferred as per batch items provided. /// @dev This function does not modify state and should only be used for simulation purposes. This function cannot /// be called within a checks-deferrable call. /// @param items An array of batch items to be executed. /// @return batchItemsResult An array of batch item results for each item. /// @return accountsStatusCheckResult An array of account status check results for each account. /// @return vaultsStatusCheckResult An array of vault status check results for each vault. function batchSimulation(BatchItem[] calldata items) external payable returns ( BatchItemResult[] memory batchItemsResult, StatusCheckResult[] memory accountsStatusCheckResult, StatusCheckResult[] memory vaultsStatusCheckResult ); /// @notice Retrieves the timestamp of the last successful account status check performed for a specific account. /// @dev This function reverts if the checks are in progress. /// @dev The account status check is considered to be successful if it calls into the selected controller vault and /// obtains expected magic value. This timestamp does not change if the account status is considered valid when no /// controller enabled. When consuming, one might need to ensure that the account status check is not deferred at /// the moment. /// @param account The address of the account for which the last status check timestamp is being queried. /// @return The timestamp of the last status check as a uint256. function getLastAccountStatusCheckTimestamp(address account) external view returns (uint256); /// @notice Checks whether the status check is deferred for a given account. /// @dev This function reverts if the checks are in progress. /// @param account The address of the account for which it is checked whether the status check is deferred. /// @return A boolean flag that indicates whether the status check is deferred or not. function isAccountStatusCheckDeferred(address account) external view returns (bool); /// @notice Checks the status of an account and reverts if it is not valid. /// @dev If checks deferred, the account is added to the set of accounts to be checked at the end of the outermost /// checks-deferrable call. There can be at most 10 unique accounts added to the set at a time. Account status /// check is performed by calling into the selected controller vault and passing the array of currently enabled /// collaterals. If controller is not selected, the account is always considered valid. /// @param account The address of the account to be checked. function requireAccountStatusCheck(address account) external payable; /// @notice Forgives previously deferred account status check. /// @dev Account address is removed from the set of addresses for which status checks are deferred. This function /// can only be called by the currently enabled controller of a given account. Depending on the vault /// implementation, may be needed in the liquidation flow. /// @param account The address of the account for which the status check is forgiven. function forgiveAccountStatusCheck(address account) external payable; /// @notice Checks whether the status check is deferred for a given vault. /// @dev This function reverts if the checks are in progress. /// @param vault The address of the vault for which it is checked whether the status check is deferred. /// @return A boolean flag that indicates whether the status check is deferred or not. function isVaultStatusCheckDeferred(address vault) external view returns (bool); /// @notice Checks the status of a vault and reverts if it is not valid. /// @dev If checks deferred, the vault is added to the set of vaults to be checked at the end of the outermost /// checks-deferrable call. There can be at most 10 unique vaults added to the set at a time. This function can /// only be called by the vault itself. function requireVaultStatusCheck() external payable; /// @notice Forgives previously deferred vault status check. /// @dev Vault address is removed from the set of addresses for which status checks are deferred. This function can /// only be called by the vault itself. function forgiveVaultStatusCheck() external payable; /// @notice Checks the status of an account and a vault and reverts if it is not valid. /// @dev If checks deferred, the account and the vault are added to the respective sets of accounts and vaults to be /// checked at the end of the outermost checks-deferrable call. Account status check is performed by calling into /// selected controller vault and passing the array of currently enabled collaterals. If controller is not selected, /// the account is always considered valid. This function can only be called by the vault itself. /// @param account The address of the account to be checked. function requireAccountAndVaultStatusCheck(address account) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; type EC is uint256; /// @title ExecutionContext /// @custom:security-contact [email protected] /// @author Euler Labs (https://www.eulerlabs.com/) /// @notice This library provides functions for managing the execution context in the Ethereum Vault Connector. /// @dev The execution context is a bit field that stores the following information: /// @dev - on behalf of account - an account on behalf of which the currently executed operation is being performed /// @dev - checks deferred flag - used to indicate whether checks are deferred /// @dev - checks in progress flag - used to indicate that the account/vault status checks are in progress. This flag is /// used to prevent re-entrancy. /// @dev - control collateral in progress flag - used to indicate that the control collateral is in progress. This flag /// is used to prevent re-entrancy. /// @dev - operator authenticated flag - used to indicate that the currently executed operation is being performed by /// the account operator /// @dev - simulation flag - used to indicate that the currently executed batch call is a simulation /// @dev - stamp - dummy value for optimization purposes library ExecutionContext { uint256 internal constant ON_BEHALF_OF_ACCOUNT_MASK = 0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; uint256 internal constant CHECKS_DEFERRED_MASK = 0x0000000000000000000000FF0000000000000000000000000000000000000000; uint256 internal constant CHECKS_IN_PROGRESS_MASK = 0x00000000000000000000FF000000000000000000000000000000000000000000; uint256 internal constant CONTROL_COLLATERAL_IN_PROGRESS_LOCK_MASK = 0x000000000000000000FF00000000000000000000000000000000000000000000; uint256 internal constant OPERATOR_AUTHENTICATED_MASK = 0x0000000000000000FF0000000000000000000000000000000000000000000000; uint256 internal constant SIMULATION_MASK = 0x00000000000000FF000000000000000000000000000000000000000000000000; uint256 internal constant STAMP_OFFSET = 200; // None of the functions below modifies the state. All the functions operate on the copy // of the execution context and return its modified value as a result. In order to update // one should use the result of the function call as a new execution context value. function getOnBehalfOfAccount(EC self) internal pure returns (address result) { result = address(uint160(EC.unwrap(self) & ON_BEHALF_OF_ACCOUNT_MASK)); } function setOnBehalfOfAccount(EC self, address account) internal pure returns (EC result) { result = EC.wrap((EC.unwrap(self) & ~ON_BEHALF_OF_ACCOUNT_MASK) | uint160(account)); } function areChecksDeferred(EC self) internal pure returns (bool result) { result = EC.unwrap(self) & CHECKS_DEFERRED_MASK != 0; } function setChecksDeferred(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) | CHECKS_DEFERRED_MASK); } function areChecksInProgress(EC self) internal pure returns (bool result) { result = EC.unwrap(self) & CHECKS_IN_PROGRESS_MASK != 0; } function setChecksInProgress(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) | CHECKS_IN_PROGRESS_MASK); } function isControlCollateralInProgress(EC self) internal pure returns (bool result) { result = EC.unwrap(self) & CONTROL_COLLATERAL_IN_PROGRESS_LOCK_MASK != 0; } function setControlCollateralInProgress(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) | CONTROL_COLLATERAL_IN_PROGRESS_LOCK_MASK); } function isOperatorAuthenticated(EC self) internal pure returns (bool result) { result = EC.unwrap(self) & OPERATOR_AUTHENTICATED_MASK != 0; } function setOperatorAuthenticated(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) | OPERATOR_AUTHENTICATED_MASK); } function clearOperatorAuthenticated(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) & ~OPERATOR_AUTHENTICATED_MASK); } function isSimulationInProgress(EC self) internal pure returns (bool result) { result = EC.unwrap(self) & SIMULATION_MASK != 0; } function setSimulationInProgress(EC self) internal pure returns (EC result) { result = EC.wrap(EC.unwrap(self) | SIMULATION_MASK); } }
{ "remappings": [ "lib/euler-price-oracle:@openzeppelin/contracts/=lib/euler-price-oracle/lib/openzeppelin-contracts/contracts/", "lib/native-token-transfers/evm:openzeppelin-contracts/contracts/=lib/native-token-transfers/evm/lib/openzeppelin-contracts/contracts/", "lib/euler-earn:@openzeppelin/=lib/euler-earn/lib/openzeppelin-contracts/", "lib/euler-earn:@openzeppelin-upgradeable/=lib/euler-earn/lib/openzeppelin-contracts-upgradeable/contracts/", "lib/euler-earn:ethereum-vault-connector/=lib/euler-earn/lib/ethereum-vault-connector/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "ethereum-vault-connector/=lib/ethereum-vault-connector/src/", "evc/=lib/ethereum-vault-connector/src/", "evk/=lib/euler-vault-kit/src/", "evk-test/=lib/euler-vault-kit/test/", "euler-price-oracle/=lib/euler-price-oracle/src/", "euler-price-oracle-test/=lib/euler-price-oracle/test/", "fee-flow/=lib/fee-flow/src/", "reward-streams/=lib/reward-streams/src/", "@openzeppelin/=lib/openzeppelin-contracts/contracts/", "euler-earn/=lib/euler-earn/src/", "native-token-transfers/=lib/native-token-transfers/evm/src/", "@openzeppelin-upgradeable/=lib/euler-earn/lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@pendle/core-v2/=lib/euler-price-oracle/lib/pendle-core-v2-public/contracts/", "@pyth/=lib/euler-price-oracle/lib/pyth-sdk-solidity/", "@redstone/evm-connector/=lib/euler-price-oracle/lib/redstone-oracles-monorepo/packages/evm-connector/contracts/", "@solady/=lib/euler-price-oracle/lib/solady/src/", "@uniswap/v3-core/=lib/euler-price-oracle/lib/v3-core/", "@uniswap/v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/", "ERC4626/=lib/euler-earn/lib/properties/lib/ERC4626/contracts/", "crytic-properties/=lib/euler-earn/lib/properties/contracts/", "ds-test/=lib/ethereum-vault-connector/lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/", "euler-vault-kit/=lib/euler-vault-kit/", "forge-gas-snapshot/=lib/euler-vault-kit/lib/permit2/lib/forge-gas-snapshot/src/", "forge-std/=lib/forge-std/src/", "halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/", "layerzero-devtools/=lib/layerzero-devtools/packages/toolbox-foundry/src/", "layerzero-v2/=lib/layerzero-v2/", "openzeppelin/=lib/ethereum-vault-connector/lib/openzeppelin-contracts/contracts/", "pendle-core-v2-public/=lib/euler-price-oracle/lib/pendle-core-v2-public/contracts/", "permit2/=lib/euler-vault-kit/lib/permit2/", "properties/=lib/euler-earn/lib/properties/contracts/", "pyth-sdk-solidity/=lib/euler-price-oracle/lib/pyth-sdk-solidity/", "redstone-oracles-monorepo/=lib/euler-price-oracle/lib/", "solady/=lib/euler-price-oracle/lib/solady/src/", "solidity-bytes-utils/=lib/native-token-transfers/evm/lib/solidity-bytes-utils/contracts/", "solmate/=lib/fee-flow/lib/solmate/src/", "v3-core/=lib/euler-price-oracle/lib/v3-core/contracts/", "v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/contracts/", "wormhole-solidity-sdk/=lib/native-token-transfers/evm/lib/wormhole-solidity-sdk/src/" ], "optimizer": { "enabled": true, "runs": 20000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"address","name":"vaultFactory_","type":"address"},{"internalType":"address","name":"routerFactory_","type":"address"},{"internalType":"address","name":"adapterRegistry_","type":"address"},{"internalType":"address","name":"externalVaultRegistry_","type":"address"},{"internalType":"address","name":"irmFactory_","type":"address"},{"internalType":"address","name":"irmRegistry_","type":"address"},{"internalType":"address[]","name":"recognizedUnitOfAccounts_","type":"address[]"},{"internalType":"address[]","name":"recognizedCollateralPerspectives_","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"perspective","type":"address"},{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"codes","type":"uint256"}],"name":"PerspectiveError","type":"error"},{"inputs":[],"name":"PerspectivePanic","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"}],"name":"PerspectiveVerified","type":"event"},{"inputs":[],"name":"adapterRegistry","outputs":[{"internalType":"contract SnapshotRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"externalVaultRegistry","outputs":[{"internalType":"contract SnapshotRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"irmFactory","outputs":[{"internalType":"contract IEulerKinkIRMFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"irmRegistry","outputs":[{"internalType":"contract SnapshotRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"unitOfAccount","type":"address"}],"name":"isRecognizedUnitOfAccount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"isVerified","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"bool","name":"failEarly","type":"bool"}],"name":"perspectiveVerify","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"recognizedCollateralPerspectives","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"routerFactory","outputs":[{"internalType":"contract IEulerRouterFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultFactory","outputs":[{"internalType":"contract GenericFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"verifiedArray","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"verifiedLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61014060405234801562000011575f80fd5b50604051620027b2380380620027b28339810160408190526200003491620002f4565b6001600160a01b03881660805260066200004f8a8262000477565b506001600160a01b0380881660a05286811660c05285811660e052848116610120528316610100525f5b8251811015620000d757600160075f8584815181106200009d576200009d62000543565b6020908102919091018101516001600160a01b031682528101919091526040015f20805460ff191691151591909117905560010162000079565b508051620000ed906008906020840190620000fd565b5050505050505050505062000557565b828054828255905f5260205f2090810192821562000153579160200282015b828111156200015357825182546001600160a01b0319166001600160a01b039091161782556020909201916001909101906200011c565b506200016192915062000165565b5090565b5b8082111562000161575f815560010162000166565b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f191681016001600160401b0381118282101715620001ba57620001ba6200017b565b604052919050565b5f82601f830112620001d2575f80fd5b81516001600160401b03811115620001ee57620001ee6200017b565b602062000204601f8301601f191682016200018f565b828152858284870101111562000218575f80fd5b5f5b83811015620002375785810183015182820184015282016200021a565b505f928101909101919091529392505050565b80516001600160a01b038116811462000261575f80fd5b919050565b5f82601f83011262000276575f80fd5b815160206001600160401b038211156200029457620002946200017b565b8160051b620002a58282016200018f565b9283528481018201928281019087851115620002bf575f80fd5b83870192505b84831015620002e957620002d9836200024a565b82529183019190830190620002c5565b979650505050505050565b5f805f805f805f805f6101208a8c0312156200030e575f80fd5b89516001600160401b038082111562000325575f80fd5b620003338d838e01620001c2565b9a506200034360208d016200024a565b99506200035360408d016200024a565b98506200036360608d016200024a565b97506200037360808d016200024a565b96506200038360a08d016200024a565b95506200039360c08d016200024a565b945060e08c0151915080821115620003a9575f80fd5b620003b78d838e0162000266565b93506101008c0151915080821115620003ce575f80fd5b50620003dd8c828d0162000266565b9150509295985092959850929598565b600181811c908216806200040257607f821691505b6020821081036200042157634e487b7160e01b5f52602260045260245ffd5b50919050565b601f8211156200047257805f5260205f20601f840160051c810160208510156200044e5750805b601f840160051c820191505b818110156200046f575f81556001016200045a565b50505b505050565b81516001600160401b038111156200049357620004936200017b565b620004ab81620004a48454620003ed565b8462000427565b602080601f831160018114620004e1575f8415620004c95750858301515b5f19600386901b1c1916600185901b1785556200053b565b5f85815260208120601f198616915b828110156200051157888601518255948401946001909101908401620004f0565b50858210156200052f57878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52603260045260245ffd5b60805160a05160c05160e05161010051610120516121db620005d75f395f81816101e301526109dc01525f818161012c0152610a9601525f818161025401526116ee01525f81816101b4015261191f01525f818161018d0152610e0701525f818161022d015281816105820152818161063d015261078a01526121db5ff3fe608060405234801561000f575f80fd5b50600436106100da575f3560e01c806350b5c16a11610088578063b9209e3311610063578063b9209e3314610205578063d8a06f7314610228578063db3aa8f51461024f578063ddcb471614610276575f80fd5b806350b5c16a146101af5780638d5e21d3146101d6578063a93f3b16146101de575f80fd5b80631fd2df3f116100b85780631fd2df3f146101275780632e5896e5146101735780634ba5143714610188575f80fd5b806306fdde03146100de578063138721d9146100fc5780631794731714610112575b5f80fd5b6100e66102ae565b6040516100f39190611c33565b60405180910390f35b61010461033e565b6040519081526020016100f3565b61011a61034d565b6040516100f39190611c83565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f3565b610186610181366004611d0d565b6103b9565b005b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b61011a6104e3565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b610218610213366004611d44565b6104ee565b60405190151581526020016100f3565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b61014e7f000000000000000000000000000000000000000000000000000000000000000081565b610218610284366004611d44565b73ffffffffffffffffffffffffffffffffffffffff165f9081526007602052604090205460ff1690565b6060600680546102bd90611d5f565b80601f01602080910402602001604051908101604052809291908181526020018280546102e990611d5f565b80156103345780601f1061030b57610100808354040283529160200191610334565b820191905f5260205f20905b81548152906001019060200180831161031757829003601f168201915b5050505050905090565b5f6103485f6104ff565b905090565b6060600880548060200260200160405190810160405280929190818152602001828054801561033457602002820191905f5260205f20905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610385575050505050905090565b5f8281526002602052604090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff815c016103f057005b6103fa5f84610508565b1561040457505050565b6004805c9060055c9085905d8360055d6001835d61042185610539565b5f8260045d8160055d5060035c8015610490576040517f818fa2cf00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff87166024820152604481018290526064015b60405180910390fd5b61049a5f87611465565b5060405173ffffffffffffffffffffffffffffffffffffffff8716907f570e1c1f1f2e6e95bfd6d0cae607f36c3cd5ebb7bc35c2f87299924b1bcd3920905f90a2505050505050565b60606103485f611486565b5f6104f98183610508565b92915050565b5f6104f9825490565b73ffffffffffffffffffffffffffffffffffffffff81165f90815260018301602052604081205415155b9392505050565b6040517f2971038800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526105f4917f000000000000000000000000000000000000000000000000000000000000000090911690632971038890602401602060405180830381865afa1580156105c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ed9190611db0565b6001611492565b6040517fa20ea5c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526106d0917f00000000000000000000000000000000000000000000000000000000000000009091169063a20ea5c1906024015f60405180830381865afa158015610683573d5f803e3d5ffd5b505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526106c89190810190611e70565b516004611492565b5f8173ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561071a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061073e9190611f6e565b6040517f2971038800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192506107fb917f00000000000000000000000000000000000000000000000000000000000000001690632971038890602401602060405180830381865afa1580156107cf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f39190611db0565b156010611492565b6108a15f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16636ce98c296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561085e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108829190611f6e565b73ffffffffffffffffffffffffffffffffffffffff1614611000611492565b6109226113888373ffffffffffffffffffffffffffffffffffffffff1663a75df4986040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108f0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109149190611f9f565b61ffff161115614000611492565b5f8273ffffffffffffffffffffffffffffffffffffffff1663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561096c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109909190611f6e565b6040517f6ee0787a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152919250610b07917f00000000000000000000000000000000000000000000000000000000000000001690636ee0787a90602401602060405180830381865afa158015610a21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a459190611db0565b80610aff57506040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301524260248301527f00000000000000000000000000000000000000000000000000000000000000001690635964798490604401602060405180830381865afa158015610adb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610aff9190611db0565b618000611492565b5f808473ffffffffffffffffffffffffffffffffffffffff1663cf349b7d6040518163ffffffff1660e01b81526004016040805180830381865afa158015610b51573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b759190611fcb565b9092509050610b9e73ffffffffffffffffffffffffffffffffffffffff83161562040000611492565b610bb263ffffffff82161562080000611492565b5050610c348373ffffffffffffffffffffffffffffffffffffffff16632b38a3676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c249190611ffe565b63ffffffff161562100000611492565b5f8373ffffffffffffffffffffffffffffffffffffffff16634f7e43df6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c7e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ca29190611f9f565b9050610ccc6101f48261ffff1610158015610cc357506107d08261ffff1611155b62800000611492565b610d4d8473ffffffffffffffffffffffffffffffffffffffff16634abdb9596040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d18573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3c9190611f9f565b61ffff166001146301000000611492565b5f8473ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d97573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dbb9190611f6e565b6040517f6ee0787a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152919250610e77917f00000000000000000000000000000000000000000000000000000000000000001690636ee0787a90602401602060405180830381865afa158015610e4c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e709190611db0565b6020611492565b610f1c5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610efe9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff16146040611492565b610fc15f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1663629838e56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f7f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fa39190611f6e565b73ffffffffffffffffffffffffffffffffffffffff16146080611492565b5f8573ffffffffffffffffffffffffffffffffffffffff16633e8333646040518163ffffffff1660e01b8152600401602060405180830381865afa15801561100b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061102f9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff81165f908152600760205260409020549091506110669060ff16610400611492565b61107182868361154a565b5f8673ffffffffffffffffffffffffffffffffffffffff16636a16ef846040518163ffffffff1660e01b81526004015f60405180830381865afa1580156110ba573d5f803e3d5ffd5b505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526110ff9190810190612017565b80519091506111148115156302000000611492565b5f5b8181101561145a575f838281518110611131576111316120c4565b60200260200101519050611146868287611999565b6040517f33708d0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301525f918291829182918f16906333708d0c9060240160a060405180830381865afa1580156111b8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111dc91906120f1565b945094505093509350611206606485856111f6919061215e565b61ffff1610156304000000611492565b61122c5f8561ffff1611801561122257506126488561ffff1611155b6308000000611492565b6112525f8461ffff1611801561124857506126488461ffff1611155b6310000000611492565b61127a63ffffffff821615806112705750428365ffffffffffff1611155b6320000000611492565b6008545f90815b81811015611370575f6112c6600883815481106112a0576112a06120c4565b5f9182526020909120015473ffffffffffffffffffffffffffffffffffffffff16611b45565b6040517fb9209e3300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b811660048301529192509082169063b9209e3390602401602060405180830381865afa158015611334573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113589190611db0565b15611367576001935050611370565b50600101611281565b508161143a575f5b81811015611438575f611397600883815481106112a0576112a06120c4565b6040517f2e5896e500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b811660048301526001602483015291925090821690632e5896e5906044015f604051808303815f87803b158015611408575f80fd5b505af1925050508015611419575060015b1561142357600193505b831561142f5750611438565b50600101611378565b505b611448826340000000611492565b50505050505050806001019050611116565b505050505050505050565b5f6105328373ffffffffffffffffffffffffffffffffffffffff8416611b6c565b60605f61053283611bb8565b811561149c575050565b805f036114d5576040517fcb365b8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055c801561153b576040517f818fa2cf000000000000000000000000000000000000000000000000000000008152306004808301919091525c73ffffffffffffffffffffffffffffffffffffffff811660248301526044820184905290606401610487565b60035c82811760035d50505050565b6040517f5ca4001700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f9190851690635ca4001790602401602060405180830381865afa1580156115b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115db9190611f6e565b905073ffffffffffffffffffffffffffffffffffffffff8116156117da5761169f8173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561165c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116809190611f6e565b73ffffffffffffffffffffffffffffffffffffffff1614610100611492565b6040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152426024830152611761917f000000000000000000000000000000000000000000000000000000000000000090911690635964798490604401602060405180830381865afa158015611735573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117599190611db0565b610100611492565b6040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015283811660248301526117da915f91871690638aa77608906044015b602060405180830381865afa15801561165c573d5f803e3d5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff8216156117fd57816117ff565b835b90508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611992576040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015284811660248301525f9190871690638aa7760890604401602060405180830381865afa1580156118a9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118cd9190611f6e565b6040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152426024830152919250611990917f00000000000000000000000000000000000000000000000000000000000000001690635964798490604401602060405180830381865afa158015611964573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119889190611db0565b610200611492565b505b5050505050565b6040517f5ca4001700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f9190851690635ca4001790602401602060405180830381865afa158015611a06573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a2a9190611f6e565b9050611ad28373ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a78573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9c9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610100611492565b6040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528381166024830152611b34915f91871690638aa77608906044016117bf565b611b3f84828461154a565b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff8216611b68575030919050565b5090565b5f818152600183016020526040812054611bb157508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556104f9565b505f6104f9565b6060815f01805480602002602001604051908101604052809291908181526020018280548015611c0557602002820191905f5260205f20905b815481526020019060010190808311611bf1575b50505050509050919050565b5f5b83811015611c2b578181015183820152602001611c13565b50505f910152565b602081525f8251806020840152611c51816040850160208701611c11565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b602080825282518282018190525f9190848201906040850190845b81811015611cd057835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101611c9e565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff81168114611cfd575f80fd5b50565b8015158114611cfd575f80fd5b5f8060408385031215611d1e575f80fd5b8235611d2981611cdc565b91506020830135611d3981611d00565b809150509250929050565b5f60208284031215611d54575f80fd5b813561053281611cdc565b600181811c90821680611d7357607f821691505b602082108103611daa577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f60208284031215611dc0575f80fd5b815161053281611d00565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715611e1b57611e1b611dcb565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e6857611e68611dcb565b604052919050565b5f6020808385031215611e81575f80fd5b825167ffffffffffffffff80821115611e98575f80fd5b9084019060608287031215611eab575f80fd5b611eb3611df8565b8251611ebe81611d00565b815282840151611ecd81611cdc565b81850152604083015182811115611ee2575f80fd5b80840193505086601f840112611ef6575f80fd5b825182811115611f0857611f08611dcb565b611f38857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611e21565b92508083528785828601011115611f4d575f80fd5b611f5c81868501878701611c11565b50604081019190915295945050505050565b5f60208284031215611f7e575f80fd5b815161053281611cdc565b805161ffff81168114611f9a575f80fd5b919050565b5f60208284031215611faf575f80fd5b61053282611f89565b805163ffffffff81168114611f9a575f80fd5b5f8060408385031215611fdc575f80fd5b8251611fe781611cdc565b9150611ff560208401611fb8565b90509250929050565b5f6020828403121561200e575f80fd5b61053282611fb8565b5f6020808385031215612028575f80fd5b825167ffffffffffffffff8082111561203f575f80fd5b818501915085601f830112612052575f80fd5b81518181111561206457612064611dcb565b8060051b9150612075848301611e21565b818152918301840191848101908884111561208e575f80fd5b938501935b838510156120b857845192506120a883611cdc565b8282529385019390850190612093565b98975050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f805f805f60a08688031215612105575f80fd5b61210e86611f89565b945061211c60208701611f89565b935061212a60408701611f89565b9250606086015165ffffffffffff81168114612144575f80fd5b915061215260808701611fb8565b90509295509295909350565b61ffff82811682821603908082111561219e577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b509291505056fea2646970667358221220b39f28f89ffaa1da747ee81370c5105b3d72f011acc5147778e1312cac58dfe864736f6c634300081800330000000000000000000000000000000000000000000000000000000000000120000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb000000000000000000000000c5b9b95a769c24c18c344c2659db61a0adfb736e00000000000000000000000093fd7a2b4e6bea3c35d06468a7bd7b0ea202d075000000000000000000000000650737bf472588a04530494189c3c30eaf5f6c5000000000000000000000000052e856790779fd4fca34ba52c67cd191338572c0000000000000000000000000c16f26f5edb152b99443468fd85b9f41e4ac8ac3000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000001f45756c657220556e676f7665726e6564203078205065727370656374697665000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000034800000000000000000000000050c42deacd8fc9773493ed674b675be577f2634b000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000000020000000000000000000000004f51fbd2161fc5e41295b866cb42a08e7ea39a250000000000000000000000000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106100da575f3560e01c806350b5c16a11610088578063b9209e3311610063578063b9209e3314610205578063d8a06f7314610228578063db3aa8f51461024f578063ddcb471614610276575f80fd5b806350b5c16a146101af5780638d5e21d3146101d6578063a93f3b16146101de575f80fd5b80631fd2df3f116100b85780631fd2df3f146101275780632e5896e5146101735780634ba5143714610188575f80fd5b806306fdde03146100de578063138721d9146100fc5780631794731714610112575b5f80fd5b6100e66102ae565b6040516100f39190611c33565b60405180910390f35b61010461033e565b6040519081526020016100f3565b61011a61034d565b6040516100f39190611c83565b61014e7f000000000000000000000000c16f26f5edb152b99443468fd85b9f41e4ac8ac381565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100f3565b610186610181366004611d0d565b6103b9565b005b61014e7f000000000000000000000000c5b9b95a769c24c18c344c2659db61a0adfb736e81565b61014e7f00000000000000000000000093fd7a2b4e6bea3c35d06468a7bd7b0ea202d07581565b61011a6104e3565b61014e7f00000000000000000000000052e856790779fd4fca34ba52c67cd191338572c081565b610218610213366004611d44565b6104ee565b60405190151581526020016100f3565b61014e7f000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb81565b61014e7f000000000000000000000000650737bf472588a04530494189c3c30eaf5f6c5081565b610218610284366004611d44565b73ffffffffffffffffffffffffffffffffffffffff165f9081526007602052604090205460ff1690565b6060600680546102bd90611d5f565b80601f01602080910402602001604051908101604052809291908181526020018280546102e990611d5f565b80156103345780601f1061030b57610100808354040283529160200191610334565b820191905f5260205f20905b81548152906001019060200180831161031757829003601f168201915b5050505050905090565b5f6103485f6104ff565b905090565b6060600880548060200260200160405190810160405280929190818152602001828054801561033457602002820191905f5260205f20905b815473ffffffffffffffffffffffffffffffffffffffff168152600190910190602001808311610385575050505050905090565b5f8281526002602052604090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff815c016103f057005b6103fa5f84610508565b1561040457505050565b6004805c9060055c9085905d8360055d6001835d61042185610539565b5f8260045d8160055d5060035c8015610490576040517f818fa2cf00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff87166024820152604481018290526064015b60405180910390fd5b61049a5f87611465565b5060405173ffffffffffffffffffffffffffffffffffffffff8716907f570e1c1f1f2e6e95bfd6d0cae607f36c3cd5ebb7bc35c2f87299924b1bcd3920905f90a2505050505050565b60606103485f611486565b5f6104f98183610508565b92915050565b5f6104f9825490565b73ffffffffffffffffffffffffffffffffffffffff81165f90815260018301602052604081205415155b9392505050565b6040517f2971038800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526105f4917f000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb90911690632971038890602401602060405180830381865afa1580156105c9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105ed9190611db0565b6001611492565b6040517fa20ea5c100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526106d0917f000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb9091169063a20ea5c1906024015f60405180830381865afa158015610683573d5f803e3d5ffd5b505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526106c89190810190611e70565b516004611492565b5f8173ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561071a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061073e9190611f6e565b6040517f2971038800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192506107fb917f000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb1690632971038890602401602060405180830381865afa1580156107cf573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f39190611db0565b156010611492565b6108a15f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16636ce98c296040518163ffffffff1660e01b8152600401602060405180830381865afa15801561085e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108829190611f6e565b73ffffffffffffffffffffffffffffffffffffffff1614611000611492565b6109226113888373ffffffffffffffffffffffffffffffffffffffff1663a75df4986040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108f0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109149190611f9f565b61ffff161115614000611492565b5f8273ffffffffffffffffffffffffffffffffffffffff1663f3fdb15a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561096c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109909190611f6e565b6040517f6ee0787a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152919250610b07917f00000000000000000000000052e856790779fd4fca34ba52c67cd191338572c01690636ee0787a90602401602060405180830381865afa158015610a21573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a459190611db0565b80610aff57506040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301524260248301527f000000000000000000000000c16f26f5edb152b99443468fd85b9f41e4ac8ac31690635964798490604401602060405180830381865afa158015610adb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610aff9190611db0565b618000611492565b5f808473ffffffffffffffffffffffffffffffffffffffff1663cf349b7d6040518163ffffffff1660e01b81526004016040805180830381865afa158015610b51573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b759190611fcb565b9092509050610b9e73ffffffffffffffffffffffffffffffffffffffff83161562040000611492565b610bb263ffffffff82161562080000611492565b5050610c348373ffffffffffffffffffffffffffffffffffffffff16632b38a3676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c00573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c249190611ffe565b63ffffffff161562100000611492565b5f8373ffffffffffffffffffffffffffffffffffffffff16634f7e43df6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c7e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ca29190611f9f565b9050610ccc6101f48261ffff1610158015610cc357506107d08261ffff1611155b62800000611492565b610d4d8473ffffffffffffffffffffffffffffffffffffffff16634abdb9596040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d18573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d3c9190611f9f565b61ffff166001146301000000611492565b5f8473ffffffffffffffffffffffffffffffffffffffff16637dc0d1d06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d97573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dbb9190611f6e565b6040517f6ee0787a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152919250610e77917f000000000000000000000000c5b9b95a769c24c18c344c2659db61a0adfb736e1690636ee0787a90602401602060405180830381865afa158015610e4c573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e709190611db0565b6020611492565b610f1c5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16630c340a246040518163ffffffff1660e01b8152600401602060405180830381865afa158015610eda573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610efe9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff16146040611492565b610fc15f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1663629838e56040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f7f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fa39190611f6e565b73ffffffffffffffffffffffffffffffffffffffff16146080611492565b5f8573ffffffffffffffffffffffffffffffffffffffff16633e8333646040518163ffffffff1660e01b8152600401602060405180830381865afa15801561100b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061102f9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff81165f908152600760205260409020549091506110669060ff16610400611492565b61107182868361154a565b5f8673ffffffffffffffffffffffffffffffffffffffff16636a16ef846040518163ffffffff1660e01b81526004015f60405180830381865afa1580156110ba573d5f803e3d5ffd5b505050506040513d5f823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526110ff9190810190612017565b80519091506111148115156302000000611492565b5f5b8181101561145a575f838281518110611131576111316120c4565b60200260200101519050611146868287611999565b6040517f33708d0c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301525f918291829182918f16906333708d0c9060240160a060405180830381865afa1580156111b8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111dc91906120f1565b945094505093509350611206606485856111f6919061215e565b61ffff1610156304000000611492565b61122c5f8561ffff1611801561122257506126488561ffff1611155b6308000000611492565b6112525f8461ffff1611801561124857506126488461ffff1611155b6310000000611492565b61127a63ffffffff821615806112705750428365ffffffffffff1611155b6320000000611492565b6008545f90815b81811015611370575f6112c6600883815481106112a0576112a06120c4565b5f9182526020909120015473ffffffffffffffffffffffffffffffffffffffff16611b45565b6040517fb9209e3300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b811660048301529192509082169063b9209e3390602401602060405180830381865afa158015611334573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113589190611db0565b15611367576001935050611370565b50600101611281565b508161143a575f5b81811015611438575f611397600883815481106112a0576112a06120c4565b6040517f2e5896e500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b811660048301526001602483015291925090821690632e5896e5906044015f604051808303815f87803b158015611408575f80fd5b505af1925050508015611419575060015b1561142357600193505b831561142f5750611438565b50600101611378565b505b611448826340000000611492565b50505050505050806001019050611116565b505050505050505050565b5f6105328373ffffffffffffffffffffffffffffffffffffffff8416611b6c565b60605f61053283611bb8565b811561149c575050565b805f036114d5576040517fcb365b8800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60055c801561153b576040517f818fa2cf000000000000000000000000000000000000000000000000000000008152306004808301919091525c73ffffffffffffffffffffffffffffffffffffffff811660248301526044820184905290606401610487565b60035c82811760035d50505050565b6040517f5ca4001700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f9190851690635ca4001790602401602060405180830381865afa1580156115b7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906115db9190611f6e565b905073ffffffffffffffffffffffffffffffffffffffff8116156117da5761169f8173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561165c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116809190611f6e565b73ffffffffffffffffffffffffffffffffffffffff1614610100611492565b6040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8481166004830152426024830152611761917f000000000000000000000000650737bf472588a04530494189c3c30eaf5f6c5090911690635964798490604401602060405180830381865afa158015611735573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117599190611db0565b610100611492565b6040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff848116600483015283811660248301526117da915f91871690638aa77608906044015b602060405180830381865afa15801561165c573d5f803e3d5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff8216156117fd57816117ff565b835b90508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614611992576040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff828116600483015284811660248301525f9190871690638aa7760890604401602060405180830381865afa1580156118a9573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906118cd9190611f6e565b6040517f5964798400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152426024830152919250611990917f00000000000000000000000093fd7a2b4e6bea3c35d06468a7bd7b0ea202d0751690635964798490604401602060405180830381865afa158015611964573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119889190611db0565b610200611492565b505b5050505050565b6040517f5ca4001700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f9190851690635ca4001790602401602060405180830381865afa158015611a06573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a2a9190611f6e565b9050611ad28373ffffffffffffffffffffffffffffffffffffffff166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611a78573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a9c9190611f6e565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610100611492565b6040517f8aa7760800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff84811660048301528381166024830152611b34915f91871690638aa77608906044016117bf565b611b3f84828461154a565b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff8216611b68575030919050565b5090565b5f818152600183016020526040812054611bb157508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556104f9565b505f6104f9565b6060815f01805480602002602001604051908101604052809291908181526020018280548015611c0557602002820191905f5260205f20905b815481526020019060010190808311611bf1575b50505050509050919050565b5f5b83811015611c2b578181015183820152602001611c13565b50505f910152565b602081525f8251806020840152611c51816040850160208701611c11565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b602080825282518282018190525f9190848201906040850190845b81811015611cd057835173ffffffffffffffffffffffffffffffffffffffff1683529284019291840191600101611c9e565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff81168114611cfd575f80fd5b50565b8015158114611cfd575f80fd5b5f8060408385031215611d1e575f80fd5b8235611d2981611cdc565b91506020830135611d3981611d00565b809150509250929050565b5f60208284031215611d54575f80fd5b813561053281611cdc565b600181811c90821680611d7357607f821691505b602082108103611daa577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f60208284031215611dc0575f80fd5b815161053281611d00565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715611e1b57611e1b611dcb565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611e6857611e68611dcb565b604052919050565b5f6020808385031215611e81575f80fd5b825167ffffffffffffffff80821115611e98575f80fd5b9084019060608287031215611eab575f80fd5b611eb3611df8565b8251611ebe81611d00565b815282840151611ecd81611cdc565b81850152604083015182811115611ee2575f80fd5b80840193505086601f840112611ef6575f80fd5b825182811115611f0857611f08611dcb565b611f38857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601611e21565b92508083528785828601011115611f4d575f80fd5b611f5c81868501878701611c11565b50604081019190915295945050505050565b5f60208284031215611f7e575f80fd5b815161053281611cdc565b805161ffff81168114611f9a575f80fd5b919050565b5f60208284031215611faf575f80fd5b61053282611f89565b805163ffffffff81168114611f9a575f80fd5b5f8060408385031215611fdc575f80fd5b8251611fe781611cdc565b9150611ff560208401611fb8565b90509250929050565b5f6020828403121561200e575f80fd5b61053282611fb8565b5f6020808385031215612028575f80fd5b825167ffffffffffffffff8082111561203f575f80fd5b818501915085601f830112612052575f80fd5b81518181111561206457612064611dcb565b8060051b9150612075848301611e21565b818152918301840191848101908884111561208e575f80fd5b938501935b838510156120b857845192506120a883611cdc565b8282529385019390850190612093565b98975050505050505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f805f805f60a08688031215612105575f80fd5b61210e86611f89565b945061211c60208701611f89565b935061212a60408701611f89565b9250606086015165ffffffffffff81168114612144575f80fd5b915061215260808701611fb8565b90509295509295909350565b61ffff82811682821603908082111561219e577f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b509291505056fea2646970667358221220b39f28f89ffaa1da747ee81370c5105b3d72f011acc5147778e1312cac58dfe864736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb000000000000000000000000c5b9b95a769c24c18c344c2659db61a0adfb736e00000000000000000000000093fd7a2b4e6bea3c35d06468a7bd7b0ea202d075000000000000000000000000650737bf472588a04530494189c3c30eaf5f6c5000000000000000000000000052e856790779fd4fca34ba52c67cd191338572c0000000000000000000000000c16f26f5edb152b99443468fd85b9f41e4ac8ac3000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001e0000000000000000000000000000000000000000000000000000000000000001f45756c657220556e676f7665726e6564203078205065727370656374697665000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000034800000000000000000000000050c42deacd8fc9773493ed674b675be577f2634b000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb00000000000000000000000000000000000000000000000000000000000000020000000000000000000000004f51fbd2161fc5e41295b866cb42a08e7ea39a250000000000000000000000000000000000000000000000000000000000000000
-----Decoded View---------------
Arg [0] : name_ (string): Euler Ungoverned 0x Perspective
Arg [1] : vaultFactory_ (address): 0xF075cC8660B51D0b8a4474e3f47eDAC5fA034cFB
Arg [2] : routerFactory_ (address): 0xc5b9B95a769C24c18c344c2659db61a0AdFB736E
Arg [3] : adapterRegistry_ (address): 0x93Fd7A2b4E6BEa3c35D06468a7Bd7b0eA202d075
Arg [4] : externalVaultRegistry_ (address): 0x650737Bf472588A04530494189c3c30eaF5f6C50
Arg [5] : irmFactory_ (address): 0x52E856790779fD4fCa34bA52C67Cd191338572C0
Arg [6] : irmRegistry_ (address): 0xc16F26F5EdB152b99443468fd85b9F41e4Ac8Ac3
Arg [7] : recognizedUnitOfAccounts_ (address[]): 0x0000000000000000000000000000000000000348,0x50c42dEAcD8Fc9773493ED674b675bE577f2634b,0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB
Arg [8] : recognizedCollateralPerspectives_ (address[]): 0x4f51FbD2161FC5e41295b866cB42A08e7eA39a25,0x0000000000000000000000000000000000000000
-----Encoded View---------------
18 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [1] : 000000000000000000000000f075cc8660b51d0b8a4474e3f47edac5fa034cfb
Arg [2] : 000000000000000000000000c5b9b95a769c24c18c344c2659db61a0adfb736e
Arg [3] : 00000000000000000000000093fd7a2b4e6bea3c35d06468a7bd7b0ea202d075
Arg [4] : 000000000000000000000000650737bf472588a04530494189c3c30eaf5f6c50
Arg [5] : 00000000000000000000000052e856790779fd4fca34ba52c67cd191338572c0
Arg [6] : 000000000000000000000000c16f26f5edb152b99443468fd85b9f41e4ac8ac3
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [8] : 00000000000000000000000000000000000000000000000000000000000001e0
Arg [9] : 000000000000000000000000000000000000000000000000000000000000001f
Arg [10] : 45756c657220556e676f7665726e656420307820506572737065637469766500
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000348
Arg [13] : 00000000000000000000000050c42deacd8fc9773493ed674b675be577f2634b
Arg [14] : 000000000000000000000000bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
Arg [15] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [16] : 0000000000000000000000004f51fbd2161fc5e41295b866cb42a08e7ea39a25
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 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.