Skip to main content

Morpho Blue API Guides

How to query the API?

Select the query you are interested in in the list below, and paste it into this window below:

Basic Queries

1. Query Morpho Blue markets

query {
markets {
items {
uniqueKey
lltv
oracleAddress
irmAddress
loanAsset {
address
symbol
decimals
}
collateralAsset {
address
symbol
decimals
}
state {
borrowApy
borrowAssets
borrowAssetsUsd
supplyApy
supplyAssets
supplyAssetsUsd
fee
utilization
}
}
}
}

2. Query MetaMorpho vaults and their current states

query {
vaults {
items {
name
symbol
address
asset {
address
symbol
decimals
}
chain {
id
network
}
state {
totalAssets
totalAssetsUsd
apy
}
}
}
}

3. Query assets current oracle price (USD) and spot price (ETH)

query {
assets {
items {
symbol
address
priceUsd
spotPriceEth
}
}
}

Advanced Queries with variables

1. Query hourly borrow and supply APY for a specific market

query MarketApys($options: TimeseriesOptions) {
weeklyHourlyMarketApys: marketByUniqueKey(
uniqueKey: "0x608929d6de2a10bacf1046ff157ae38df5b9f466fb89413211efb8f63c63833a"
) {
uniqueKey
historicalState {
supplyApy(options: $options) {
x
y
}
borrowApy(options: $options) {
x
y
}
}
}
}

With the following options:

"options": {
"startTimestamp": 1707749700,
"endTimestamp": 1708354500,
"interval": HOUR,
}

2. Query current vault market allocations

query {
vaultByAddress(
address: "0xbEef047a543E45807105E51A8BBEFCc5950fcfBa"
chainId: 1
) {
id
state {
allocation {
market {
uniqueKey
}
supplyCap
supplyAssets
supplyAssetsUsd
}
}
}
}

3. Query asset price history

query {
wstETHWeeklyPriceUsd: assetByAddress(
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
chainId: 1
) {
historicalPriceUsd(
options: {
startTimestamp: 1707749700
endTimestamp: 1708354500
interval: HOUR
}
) {
x
y
}
}
}

4. Query 100 latest MetaMorpho transactions

query {
transactions(
first: 100
orderBy: Timestamp
orderDirection: Desc
where: { type_in: [MetaMorphoFee, MetaMorphoWithdraw, MetaMorphoWithdraw] }
) {
items {
hash
timestamp
type
chain {
id
network
}
user {
address
}
data {
... on VaultTransferTransactionData {
shares
assets
vault {
address
}
}
... on VaultFeeTransactionData {
shares
vault {
address
}
}
}
}
}
}

5. Query 10 biggest positions for a specific vault

query {
vaultPositions(
first: 10
orderBy: SHARES
orderDirection: Desc
where: { vaultAddress_in: ["0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB"] }
) {
items {
id
shares
assets
user {
address
}
}
}
}

6. Query account overview

query {
userByAddress(
chainId: 1
address: "0x821880a3E2bac432d67E5155e72BB655Ef65fa5E"
) {
address
marketPositions {
market {
uniqueKey
}
borrowAssets
borrowAssetsUsd
supplyAssets
supplyAssetsUsd
}
vaultPositions {
vault {
address
name
}
assets
assetsUsd
shares
}
transactions {
hash
timestamp
type
}
}
}

7. Query with paging, ordering and the filtering capabilities.

query {
markets(
first: 3
skip: 1
orderBy: Lltv
orderDirection: Desc
where: {
collateralAssetAddress_in: ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"]
}
) {
pageInfo {
count
countTotal
}
items {
uniqueKey
lltv
collateralAsset {
symbol
}
loanAsset {
symbol
}
}
}
}

8. Query to get markets and vaults potential warnings.

a. Warnings type are:

For Morpho Blue markets:

  • unrecognized_collateral_asset,
  • unrecognized_oracle,
  • unrecognized_loan_asset,
  • bad_debt_realized.

And for MetaMorpho:

  • unrecognized_deposit_asset,
  • unrecognized_vault_curator.

b. Warning level is either:

  • YELLOW,
  • RED.
query {
markets {
items {
uniqueKey
warnings {
type
level
}
}
}
}

query {
vaults {
items {
name
warnings {
type
level
}
}
}
}