Morpho Subgraphs
Introduction
The Morpho Subgraphs provide a powerful and efficient way to access and retrieve data from the Morpho Protocol using GraphQL. These subgraphs index onchain data for all Morpho Markets and Morpho Vaults, making it easy for developers to track protocol activity, user positions, and other key analytics without needing to process raw blockchain data directly.
The subgraphs follow the Messari Schema standard for Lending protocols, ensuring a familiar and standardized data structure. Note that some entity names may differ from Morpho's internal naming to align with this standard.
Disclaimer: Open-Source and Community Maintained
The Morpho Subgraphs are open-source and maintained by the community. The source code is available in the morpho-blue-subgraph repository on GitHub.
Please be aware that Morpho Association does not provide official support for these subgraphs. Developers are encouraged to understand the code and use it at their own discretion.
Accessing the Subgraphs
To query the subgraphs, you need a basic understanding of GraphQL. All subgraphs are accessible through The Graph's decentralized network.
-
Explore in the Playground: You can find all official deployments on The Graph Explorer. Select a subgraph and use the "Playground" tab to write and test queries directly in your browser.
-
Programmatic Access (API Key): For use in applications or scripts, you must generate an API key from The Graph Studio. Add this key to the query URL provided on each subgraph's explorer page.
Subgraph Studio users start on a free plan, which is sufficient for most development and testing purposes. For more details on pricing and query limits, refer to The Graph's official documentation.
Subgraph Deployments
Here is a list of the official subgraph deployments across various networks:
- Ethereum Mainnet
- Base
- Arbitrum
- Corn
- Fraxtal
- Hemi
- Ink
- MODE
- OP Mainnet
- Polygon POS
- Scroll
- Sonic
- Unichain
Query Examples
Morpho Market Examples
1. BorrowAPY
This query retrieves the annualized borrow rate for the top 100 markets.
{
interestRates(
first: 100
where: { side: BORROWER }
orderBy: market__totalValueLockedUSD
orderDirection: desc
) {
id
rate
side
}
}
The returned rate
is an annualized value. To get the APY, you can use the formula: BorrowAPY = e^(rate) - 1
.
2. SupplyAPY
This query retrieves the annualized supply rate for the top 100 markets.
{
interestRates(
first: 100
where: { side: LENDER }
orderBy: market__totalValueLockedUSD
orderDirection: desc
) {
id
rate
side
}
}
Similarly, the SupplyAPY
can be calculated as e^(rate) - 1
.
3. Market Data
This query fetches comprehensive data for the top 1000 markets by TVL.
{
markets(first: 1000, orderBy: totalValueLockedUSD, orderDirection: desc) {
id
name
isActive
inputToken {
name
}
borrowedToken {
name
symbol
}
totalValueLockedUSD
totalBorrowBalanceUSD
totalDepositBalanceUSD
cumulativeBorrowUSD
cumulativeDepositUSD
maximumLTV
liquidationThreshold
liquidationPenalty
}
}
4. Positions Data
This query retrieves all positions for the first 1000 accounts.
{
accounts(first: 1000) {
id
positionCount
openPositionCount
positions {
id
market {
id
}
asset {
id
}
side
isCollateral
balance
}
}
}
Morpho Vault Examples
1. Vault-Specific Data
This query fetches detailed configuration data for a specific Morpho Vault.
{
metaMorphos(where: { id: "0xbeef02e5e13584ab96848af90261f0c8ee04722a" }) {
id
name
symbol
owner {
id
}
curator {
id
}
fee
asset {
id
}
supplyQueue {
market {
id
}
}
withdrawQueue {
market {
id
}
}
timelock
}
}
Questions
If you have any questions or need further assistance, please don't hesitate to reach out on Discord.