Subgraphs
Subgraphs are a powerful way to index and query on-chain data from Euler V2 smart contracts. They allow developers, analysts, and integrators to access protocol data efficiently using GraphQL, without needing to parse events or maintain their own indexing infrastructure.
Euler maintains multiple subgraphs, each tailored to a specific network where the protocol is deployed. These subgraphs are hosted on both Goldsky and The Graph, providing reliable and fast access to historical and real-time data.
Source Code
The source code for all Euler subgraphs is open source and available on GitHub. It includes the GraphQL schema, entity definitions, and event handling logic for all supported networks.
Available Networks and Endpoints
Each network where Euler is live has its own dedicated subgraph instance. Below are the main GraphQL endpoints hosted by Goldsky:
You can also find subgraphs hosted on The Graph's hosted service. For a full list, visit the The Graph Explorer.
How to Get Active Positions of an Account
A common question is how to retrieve all active positions (deposits and borrows) for a given account in Euler. While a dedicated API is in development, you can already do this efficiently using the subgraph and lens contracts.
Step 1: Query the Subgraph for Active Positions
Use the trackingActiveAccount
query to get all positions and their associated vaults for a given address:
query Accounts($address: ID!) {
trackingActiveAccount(id: $address) {
mainAddress
deposits
borrows
}
}
This will return lists of deposits and borrows, each entry formatted as ${position}${vault}
(e.g., 0x4eda703f4D792B093cd64e452CBa7cA0ed06F6e76d671b9c618d5486814feb777552ba723f1a235c
).
To parse these entries in JavaScript:
const vault = `0x${entry.substring(42)}`;
const subAccount = entry.substring(0, 42);
subAccount
is the address of the sub-account holding the positionvault
is the address of the vault
Step 2: Fetch Detailed Data Using Lens Contracts
Once you have the list of sub-accounts and vaults, use the lens contracts for detailed information:
- Use
AccountLens
for account-level data (balances, health, rewards, etc.) - Use
VaultLens
for vault-specific details (configuration, caps, rates, etc.)
Step 3: Vault Verification with Perspectives
For the list of vaults, you can use Perspectives
to check whether a vault is verified and meets your criteria. This helps filter for trusted or curated vaults.