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
}
}
}
4. Query the Public Allocator address linked to a deployed version of Morpho Blue.
query {
publicAllocators {
items {
address
creationBlockNumber
morphoBlue {
address
chain {
id
network
}
}
}
}
}
5. Query to get the reallocations that occurred for a MetaMorpho Vault.
query {
publicAllocatorReallocates(
where: { vaultAddress_in: ["0xBEEf050ecd6a16c4e7bfFbB52Ebba7846C4b8cD4"] }
) {
items {
timestamp
assets
type
vault {
address
}
market {
uniqueKey
}
}
}
}
6. Query to get the config of the Public Allocator for a MetaMorpho Vault.
query {
vaultByAddress(
address: "0x38989BBA00BDF8181F4082995b3DEAe96163aC5D"
chainId: 1
) {
address
publicAllocatorConfig {
fee
flowCaps {
market {
uniqueKey
}
maxIn
maxOut
}
}
}
}
Advanced Queries with more 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
}
}
}
}
9. Query to get liquidations that occurred on specific markets.
query {
transactions(
where: {
marketUniqueKey_in: [
"0x49bb2d114be9041a787432952927f6f144f05ad3e83196a7d062f374ee11d0ee"
"0x093d5b432aace8bf6c4d67494f4ac2542a499571ff7a1bcc9f8778f3200d457d"
]
type_in: [MarketLiquidation]
}
) {
items {
blockNumber
hash
type
user {
address
}
data {
... on MarketLiquidationTransactionData {
seizedAssets
repaidAssets
seizedAssetsUsd
repaidAssetsUsd
badDebtAssetsUsd
liquidator
market {
uniqueKey
}
}
}
}
}
}