Skip to main content

Guides

Morpho Blue Examples

1. BorrowAPY

  1. Query:
{
interestRates(first: 100, where: { side: BORROWER }) {
id
rate
side
}
}
  1. One should get a similar as what follows:
{
"data": {
"interestRates": [
{
"id": "0x06f2842602373d247c4934f7656e513955ccc4c377f0febc0d9ca2c3bcc191b1-borrow",
"rate": "0.016527439450512",
"side": "BORROWER"
},
{
"id": "0x3a85e619751152991742810df6ec69ce473daef99e28a64ab2340d7b7ccfee49-borrow",
"rate": "0.048016387927728",
"side": "BORROWER"
},
... // truncated
]
}
}

This provides you with the annualized rate for the market with their id alongside.

BorrowAPY=(e(rate)1)\text{BorrowAPY} = (e^{(\text{rate})} - 1)

2. SupplyAPY

  1. Query:
{
interestRates(first: 100, where: { side: LENDER }) {
id
rate
side
}
}
  1. One should get the following output:
{
"data": {
"interestRates": [
{
"id": "0x06f2842602373d247c4934f7656e513955ccc4c377f0febc0d9ca2c3bcc191b1-supply",
"rate": "0.014872702563317315470846118415552",
"side": "LENDER"
},
{
"id": "0x3a85e619751152991742810df6ec69ce473daef99e28a64ab2340d7b7ccfee49-supply",
"rate": "0.020498493362733376611909270200064",
"side": "LENDER"
},
... // truncated
]
}
}

This provides you with the annualized rate for the market with their id alongside.

SupplyAPY=(e(rate)1)\text{SupplyAPY} = (e^{(\text{rate})} - 1)

3. Market Data

  1. Query:
{
markets(first: 1000) {
borrowCount
borrowingPositionCount
borrowedToken {
name
symbol
}
closedPositionCount
collateralPositionCount
createdBlockNumber
createdTimestamp
cumulativeBorrowUSD
cumulativeDepositUSD
cumulativeFlashloanUSD
cumulativeLiquidateUSD
cumulativeProtocolSideRevenueUSD
cumulativeTotalRevenueUSD
cumulativeSupplySideRevenueUSD
cumulativeTransferUSD
cumulativeUniqueBorrowers
cumulativeUniqueDepositors
cumulativeUniqueFlashloaners
cumulativeUniqueLiquidatees
cumulativeUniqueLiquidators
cumulativeUniqueUsers
cumulativeUniqueTransferrers
depositCount
fee
flashloanCount
id
inputTokenBalance
inputToken {
name
}
inputTokenPriceUSD
interest
isActive
lendingPositionCount
liquidationCount
liquidationPenalty
liquidationThreshold
maximumLTV
name
openPositionCount
positionCount
relation
repayCount
reserveFactor
reserves
supplyIndex
totalBorrow
totalBorrowBalanceUSD
totalBorrowShares
totalDepositBalanceUSD
totalCollateral
totalSupply
totalSupplyShares
totalValueLockedUSD
transactionCount
transferCount
variableBorrowedTokenBalance
withdrawCount
}
}
  1. One should get the following output:
{
"data": {
"markets": [
{
"id": "0x06f2842602373d247c4934f7656e513955ccc4c377f0febc0d9ca2c3bcc191b1",
"borrowCount": 6,
"borrowingPositionCount": 3,
"borrowedToken": {
"name": "USD Coin",
"symbol": "USDC"
},
"closedPositionCount": 5,
"collateralPositionCount": 3,
"createdBlockNumber": "19042690",
"createdTimestamp": "1705688783",
"cumulativeBorrowUSD": "952160968978.7892464079246",
"cumulativeDepositUSD": "1002382.272231639717241323572299668",
"cumulativeFlashloanUSD": "0",
"cumulativeLiquidateUSD": "0",
"cumulativeProtocolSideRevenueUSD": "0",
"cumulativeTotalRevenueUSD": "0",
"cumulativeSupplySideRevenueUSD": "0",
"cumulativeTransferUSD": "0",
"cumulativeUniqueBorrowers": 3,
"cumulativeUniqueDepositors": 3,
"cumulativeUniqueFlashloaners": 0,
"cumulativeUniqueLiquidatees": 0,
"cumulativeUniqueLiquidators": 0,
"cumulativeUniqueUsers": 6,
"cumulativeUniqueTransferrers": 0,
"depositCount": 13,
"fee": "0",
"flashloanCount": 0,
"inputTokenBalance": "1000134",
"inputToken": {
"name": "Savings Dai"
},
"inputTokenPriceUSD": "1.05352107396930682896344424",
"interest": "10377904",
"isActive": true,
"lendingPositionCount": 6,
"liquidationCount": 0,
"liquidationPenalty": "0.010611419909044972",
"liquidationThreshold": "0.965",
"maximumLTV": "0.965",
"name": "USDC / sDAI",
"openPositionCount": 4,
"positionCount": 9,
"relation": null,
"repayCount": 2,
"reserveFactor": "0",
"reserves": "0",
"supplyIndex": null,
"totalBorrow": "900000",
"totalBorrowBalanceUSD": "0.900116784",
"totalBorrowShares": "900000000000",
"totalDepositBalanceUSD": "5.21434807326506731585377696",
"totalCollateral": "4000000000000000000",
"totalSupply": "1000134",
"totalSupplyShares": "500000000000",
"totalValueLockedUSD": "5.21434807326506731585377696",
"transactionCount": 27,
"transferCount": 0,
"variableBorrowedTokenBalance": "0",
"withdrawCount": 6
},
... // truncated
]
}
}

4. Positions Data

  1. Query:
{
accounts(first: 1000) {
id
positionCount
openPositionCount
closedPositionCount
depositCount
withdrawCount
borrowCount
repayCount
positions(first: 1000) {
id
market {
id
}
asset {
id
}
hashClosed
side
type
isCollateral
balance
principal
depositCount
withdrawCount
borrowCount
repayCount
liquidationCount
shares
depositCollateralCount
withdrawCollateralCount
}
}
}
  1. One should get the following output:
{
"data": {
"accounts": [
{
"id": "0x00000000a2318f34c1967b9f73715235da1ffb0c",
"positionCount": 1,
"openPositionCount": 1,
"closedPositionCount": 0,
"depositCount": 0,
"withdrawCount": 0,
"borrowCount": 0,
"repayCount": 0,
"positions": [
{
"id": "0x00000000a2318f34c1967b9f73715235da1ffb0c-0x80935c765bbcb123bffa374ea9c3e84511f9dabd20a8977814eaa309c7e9aeba-COLLATERAL-0",
"market": {
"id": "0x80935c765bbcb123bffa374ea9c3e84511f9dabd20a8977814eaa309c7e9aeba"
},
"asset": {
"id": "0xdf2553b3ad768b5a29957a8dbe247ccd6f318b39"
},
"hashClosed": null,
"side": "COLLATERAL",
"type": null,
"isCollateral": true,
"balance": "1000000000000000",
"principal": "1000000000000000",
"depositCount": 1,
"withdrawCount": 0,
"borrowCount": 0,
"repayCount": 0,
"liquidationCount": 0,
"shares": null,
"depositCollateralCount": 1,
"withdrawCollateralCount": 0
}
]
},
... // truncated
]
}
}

MetaMorpho Vault Examples

1. Global Data - Vault Specific

  1. Query:
{
metaMorphos(where: {id: "0xbeef02e5e13584ab96848af90261f0c8ee04722a"}) {
id
name
symbol
owner {
id
}
curator {
id
}
fee
feeRecipient {
id
}
guardian {
id
}
lastTotalAssets
asset {
id
}
account {
id
}
allocators {
id
account {
id
}
isCurrentAllocator
}
supplyQueue {
id
market {
id
}
}
withdrawQueue {
id
market {
id
}
}
timelock
}
}
  1. One should get a similar as what follows:
{
"data": {
"metaMorphos": [
{
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722a",
"name": "Steakhouse PYUSD",
"symbol": "steakPYUSD",
"owner": {
"id": "0x255c7705e8bb334dfcae438197f7c4297988085a"
},
"curator": null,
"fee": "50000000000000000",
"feeRecipient": {
"id": "0x255c7705e8bb334dfcae438197f7c4297988085a"
},
"guardian": null,
"lastTotalAssets": "249000000000",
"asset": {
"id": "0x6c3ea9036406852006290770bedfcaba0e23a0e8"
},
"account": {
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722a"
},
"allocators": [
{
"id": "0x0d61c8b6ca9669a36f351de3ae335e9689dd9c5bbeef02e5e13584ab96848af90261f0c8ee04722a",
"account": {
"id": "0x0d61c8b6ca9669a36f351de3ae335e9689dd9c5b"
},
"isCurrentAllocator": true
},
{
"id": "0xfeed60018f9eaa7df2b5e377b5cfcd630b537018beef02e5e13584ab96848af90261f0c8ee04722a",
"account": {
"id": "0xfeed60018f9eaa7df2b5e377b5cfcd630b537018"
},
"isCurrentAllocator": true
}
],
"supplyQueue": [
{
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722a124ddf1fa02a94085d1fcc35c46c7e180ddb8a0d3ec1181cf67a75341501c9e6",
"market": {
"id": "0x124ddf1fa02a94085d1fcc35c46c7e180ddb8a0d3ec1181cf67a75341501c9e6"
}
}
],
"withdrawQueue": [
{
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722a124ddf1fa02a94085d1fcc35c46c7e180ddb8a0d3ec1181cf67a75341501c9e6",
"market": {
"id": "0x124ddf1fa02a94085d1fcc35c46c7e180ddb8a0d3ec1181cf67a75341501c9e6"
}
},
{
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722ac576cddfd1ee8332d683417548801d6835fa15fb2332a647452248987a8eded3",
"market": {
"id": "0xc576cddfd1ee8332d683417548801d6835fa15fb2332a647452248987a8eded3"
}
},
{
"id": "0xbeef02e5e13584ab96848af90261f0c8ee04722af8c13c80ab8666c21fc5afa13105745cae7c1da13df596eb5054319f36655cc9",
"market": {
"id": "0xf8c13c80ab8666c21fc5afa13105745cae7c1da13df596eb5054319f36655cc9"
}
}
],
"timelock": "604800"
}
]
}
}

Questions

If you have any questions or need further assistance, please don't hesitate to reach out on Discord.