Lens Contracts
Lens contracts are specialized, read-only smart contracts designed to make it easy for developers and analysts to access and aggregate protocol data from Euler V2. They provide a convenient way to query on-chain state, combining information from multiple contracts into a single, structured response. Typically, lens contracts are meant for off-chain use only as they are not gas optimized.
What Are Lens Contracts?
In the context of Euler V2, lens contracts are part of the periphery codebase. They are not involved in protocol state changes or user funds, but instead serve as data aggregators and helpers for off-chain applications, dashboards, bots, and research tools. By using lens contracts, you can:
- Retrieve comprehensive account and vault information in a single call
- Access risk metrics, interest rates, caps, and configuration details
- Query on-chain rewards data
- Aggregate data across multiple vaults or accounts
Euler provides several lens contracts, each focused on a specific aspect of the protocol:
1. AccountLens
- Purpose: Aggregate all relevant information about a user account and its positions across vaults.
- What you can query:
- Account balances and shares in vaults
- Borrowed amounts and debt positions
- Collateral and controller status
- On-chain reward and incentive data
- Liquidity and risk metrics (e.g., time to liquidation)
2. VaultLens
- Purpose: Provide detailed information about a specific vault.
- What you can query:
- Vault configuration and parameters (caps, fees, IRM, etc.)
- Total assets, borrows, and shares
- Collateral and their LTVs
- Oracle and price data
- Interest rate model details
3. OracleLens
- Purpose: Expose information about price oracles and their configuration.
- What you can query:
- Oracle types and parameters
4. IRMLens
- Purpose: Provide metadata and parameters for interest rate models (IRMs).
- What you can query:
- IRM type (e.g., Kink, Adaptive Curve)
- Model parameters (base rate, slopes, kink point, etc.)
5. UtilsLens
- Purpose: Offer utility queries and helpers for vaults and tokens.
- What you can query:
- ERC-4626 vault info
- APYs
- Token balances and allowances
- Indicative on-chain price lookups
- Time to liquidation
6. EulerEarnVaultLens
- Purpose: Specialized lens for Euler Earn vaults.
- What you can query:
- Strategy allocations and performance
- Fee configuration
- Reward and access control data
Where to Find Lens Contracts
Lens contracts are part of the EVK Periphery repository. You can find their source code and deployment details there.
For more technical details, see the Solidity interfaces and structs in the periphery codebase, or explore the guides in this section for practical examples.