Skip to main content

How to query MetaMorpho Data thanks to the API?

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

Basic Queries

MetaMorpho vaults and their current states

query {
vaults {
items {
address
symbol
name
creationBlockNumber
creationTimestamp
creatorAddress
whitelisted
asset {
id
address
decimals
}
chain {
id
network
}
state {
id
apy
netApy
totalAssets
totalAssetsUsd
fee
timelock
}
}
}
}

Current vault market allocations

query {
vaultByAddress(
address: "0xbEef047a543E45807105E51A8BBEFCc5950fcfBa"
chainId: 1
) {
address
state {
allocation {
market {
uniqueKey
loanAsset {
name
}
collateralAsset {
name
}
oracleAddress
irmAddress
lltv
}
supplyCap
supplyAssets
supplyAssetsUsd
}
}
}
}

10 latest MetaMorpho transactions

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

10 biggest positions for a specific vault

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

User's vaults positions

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

Vaults potential warnings

a. Warnings type are:

  • unrecognized_deposit_asset,
  • unrecognized_vault_curator.
  • not_whitelisted.

b. Warning level is either:

  • YELLOW,
  • RED.
query {
vaults {
items {
name
warnings {
type
level
}
}
}
}

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 variables

Historical vaults APY

query VaultApys($options: TimeseriesOptions) {
vaultByAddress(address: "0x38989BBA00BDF8181F4082995b3DEAe96163aC5D") {
address
historicalState {
apy(options: $options) {
x
y
}
netApy(options: $options) {
x
y
}
}
}
}
{
"options": {
"startTimestamp": 1716249600,
"endTimestamp": 1716422400,
"interval": "DAY"
}
}

Example: