Morpho Optimizers Subgraphs
This page describes the use of the Morpho Optimizers subgraphs: Access public data from the Morpho Protocol, including analytics, rates, and APY, programmatically. This is particularly useful for efficient retrieval of time-consuming onchain data.
It follows the Messari Schema standard for Lending protocols. In practice, some naming can differ from the classic Morpho naming to match the Messari standard.
Morpho Optimizers Subgraphs Repository
Find the repository on the morpho-org Github
Morpho Optimizers Subgraphs Playground
Explore the Playground: morpho-association/morpho-optimizers-subgraphs
Questions
If you have any questions or need further assistance, please don't hesitate to reach out on Discord.
Examples
The following queries are examples of different data one can get through the subgraph.
Last Deposit
- Query:
query {
deposits(first: 1, orderBy: blockNumber, orderDirection: desc) {
id
hash
account {
id
}
asset {
id
name
symbol
}
amount
amountUSD
timestamp
blockNumber
}
}
- One should get the following output:
{
"data": {
"deposits": [
{
"id": "0xdab1565cd9d12a950a260b2bee1046b09e5052681d254178674c1ac17ea5c90a70020000",
"hash": "0xdab1565cd9d12a950a260b2bee1046b09e5052681d254178674c1ac17ea5c90a",
"account": {
"id": "0x2068d14ee50772dd6e89c6f64f32adad0cc936ef"
},
"asset": {
"id": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"name": "Wrapped Ether",
"symbol": "WETH"
},
"amount": "25000000000000000000",
"amountUSD": "46180.5",
"timestamp": "1682931707",
"blockNumber": "17164957"
}
]
}
}
Position
- Query:
query {
accounts(first: 1) {
id
positions {
market {
id
}
asset {
id
symbol
}
side
balanceOnPool
balanceInP2P
}
}
}
- One should get the following output:
{
"data": {
"accounts": [
{
"id": "0x000000005ebfb5a950f8fdf3248e99614a7ff220",
"positions": [
{
"market": {
"id": "0x39aa39c021dfbae8fac545936693ac917d5e7563"
},
"asset": {
"id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"symbol": "USDC"
},
"side": "LENDER",
"balanceOnPool": "29715338200741",
"balanceInP2P": "0"
},
{
"market": {
"id": "0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9"
},
"asset": {
"id": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"symbol": "USDT"
},
"side": "BORROWER",
"balanceOnPool": "0",
"balanceInP2P": "24918746309754"
}
]
}
]
}
}
Last Liquidation
- Query:
query {
liquidates(first: 1, orderBy: blockNumber, orderDirection: desc) {
id
hash
gasPrice
gasUsed
blockNumber
market {
id
name
}
liquidator {
id
}
liquidatee {
id
}
asset {
id
name
symbol
lastPriceUSD
}
amount
amountUSD
profitUSD
}
}
- One should get the following output:
{
"data": {
"liquidates": [
{
"id": "0x38ab0c841de3c5f3758df0f73d1365ed3a24f9875b38b41a41d264e55708b8c261000000",
"hash": "0x38ab0c841de3c5f3758df0f73d1365ed3a24f9875b38b41a41d264e55708b8c2",
"gasPrice": null,
"gasUsed": null,
"blockNumber": "16804851",
"market": {
"id": "0x1982b2f5814301d4e9a8b0201555376e62f82428",
"name": "Morpho Aave interest bearing STETH"
},
"liquidator": {
"id": "0xd050e0a4838d74769228b49dff97241b4ef3805d"
},
"liquidatee": {
"id": "0xe7cace2d0c8039e0ad5b49e95110e91b3b58b188"
},
"asset": {
"id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"name": "USD Coin",
"symbol": "USDC",
"lastPriceUSD": "1.00291125621762623294967415"
},
"amount": "40214350558801436473",
"amountUSD": "57775.11468077603154058795781163777",
"profitUSD": "3779.68039967693664156638170996419"
}
]
}
}
Deposits/Borrowers
- Query:
{
markets(
first: 1000
where: { id: "0x030ba81f1c18d280636f32af80b9aad02cf0854e" }
) {
id
name
positions {
id
account {
id
}
side
balanceOnPool
balanceInP2P
}
}
}
- One should get the following output:
{
"data": {
"markets": [
{
"id": "0x030ba81f1c18d280636f32af80b9aad02cf0854e",
"name": "Morpho Aave interest bearing WETH",
"positions": [
{
"id": "0x00657209c6c9f678df9b6597ec9348da6300597e-0x030ba81f1c18d280636f32af80b9aad02cf0854e-LENDER-0",
"account": {
"id": "0x00657209c6c9f678df9b6597ec9348da6300597e"
},
"side": "LENDER",
"balanceOnPool": "0",
"balanceInP2P": "21812136102581728"
},
{
"id": "0x013f42b94b828da22020f9e3208922acb4bd24b3-0x030ba81f1c18d280636f32af80b9aad02cf0854e-BORROWER-0",
"account": {
"id": "0x013f42b94b828da22020f9e3208922acb4bd24b3"
},
"side": "BORROWER",
"balanceOnPool": "0",
"balanceInP2P": "46643701229607763895"
},
{
"id": "0x016b5ccd5f996d7769747d97ce026ec126a3a197-0x030ba81f1c18d280636f32af80b9aad02cf0854e-LENDER-0",
"account": {
"id": "0x016b5ccd5f996d7769747d97ce026ec126a3a197"
},
"side": "LENDER",
"balanceOnPool": "0",
"balanceInP2P": "590239976581260"
},
{
"id": "0x017ec75cd68ac9120e11f7ff5a293f782fb823d3-0x030ba81f1c18d280636f32af80b9aad02cf0854e-LENDER-0",
"account": {
"id": "0x017ec75cd68ac9120e11f7ff5a293f782fb823d3"
},
"side": "LENDER",
"balanceOnPool": "0",
"balanceInP2P": "0"
}
]
}
]
}
}