Skip to main content

How to query Morpho Blue Data thanks to the API?

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

There is a native documentation on the right of the screen into the blue-api to help you with the queries.

Basic Queries

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
}
}
}
}

Morpho Blue whitelisted markets

query {
markets(where:{whitelisted: true}) {
items {
whitelisted
uniqueKey
lltv
oracleAddress
irmAddress
loanAsset {
address
symbol
decimals
}
collateralAsset {
address
symbol
decimals
}
state {
borrowApy
borrowAssets
borrowAssetsUsd
supplyApy
supplyAssets
supplyAssetsUsd
fee
utilization
}
}
}
}

Assets current usd price and potential yield

query GetAssetsWithPrice {
assets(where: { symbol_in: ["sDAI"] }) {
items {
symbol
address
priceUsd
chain {
id
network
currency
}
yield {
apr
}
}
}
}
  • priceUsd is the current price of the asset in USD.
  • oraclePriceUsd is a deprecated field, please use priceUsd instead.

Oracle details for a given market

query {
marketByUniqueKey(
uniqueKey: "0xa72f4af2570dca1b356aa6c1e6a804d0d3df5b23bb092189776d0dc652feabb4"
chainId: 1
) {
oracle {
address
type
data {
... on MorphoChainlinkOracleData {
baseFeedOne {
address
description
vendor
pair
}
vault
}
... on MorphoChainlinkOracleV2Data {
baseFeedOne {
address
description
vendor
pair
}
}
}
}
}
}

Advanced Queries with more variables

Historical borrow and supply APY

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,
}

Feel free to play with the different variables existing into the historicalState.

Historical borrow and supply assets usd

query MarketApys($options: TimeseriesOptions) {
weeklyrlyMarketAssetsUsd: marketByUniqueKey(
uniqueKey: "0x608929d6de2a10bacf1046ff157ae38df5b9f466fb89413211efb8f63c63833a"
) {
uniqueKey
historicalState {
supplyAssetsUsd(options: $options) {
x
y
}
borrowAssetsUsd(options: $options) {
x
y
}
}
}
}

With the following options:

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

Asset price history

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

All queries sent for assetByAddress, marketByUniqueKey and vaultByAddress should include the chainId parameter.

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
}
}
}

Market(s) positions overview

query {
marketPositions(
first: 30
orderBy: SupplyShares
orderDirection: Desc
where: {
marketUniqueKey_in: [
"0x698fe98247a40c5771537b5786b2f3f9d78eb487b4ce4d75533cd0e94d88a115"
]
}
) {
items {
supplyShares
supplyAssets
supplyAssetsUsd
borrowShares
borrowAssets
borrowAssetsUsd
collateral
collateralUsd
market {
uniqueKey
loanAsset {
address
symbol
}
collateralAsset {
address
symbol
}
}
user {
address
}
}
}
}

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
}
}
}
}

List of vaults supplying into a market

query {
markets(
where: {
uniqueKey_in: [
"0x5125fcd427c196c8796f1a7573109ad9884e6ece3208c25a9583b5999b4e03e4"
]
}
) {
items {
id
uniqueKey
loanAsset {
symbol
}
collateralAsset {
symbol
}
supplyingVaults {
address
}
}
}
}

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
}
}
}
}
}
}