Skip to content

Indexer GraphQL API

Monarch exposes its Morpho market data indexer at:

text
https://indexer.monarchlend.xyz/graphql

This GraphQL API is separate from the REST Data API at https://api.monarchlend.xyz and is hosted on Envio.

The Monarch frontend uses the indexer for market registry data, live market state, historical snapshots, user positions, user transactions, market activity, and Auto Vault metadata.

What to use it for

Monarch GraphQL powers queries for:

  • Market — market registry and live market state
  • MarketHourlySnapshot / MarketDailySnapshot — historical charts
  • Position — user and market positions
  • Morpho_* event tables — supplies, borrows, withdraws, repays, liquidations
  • Vault — Auto Vault metadata, allocators, sentinels, caps, adapters
  • Adapter — adapter metadata for Vault V2

How to query it

Send a standard GraphQL POST request:

bash
curl https://indexer.monarchlend.xyz/graphql \
  -H 'Content-Type: application/json' \
  --data '{
    "query": "query { __typename }"
  }'

Example: list markets

This mirrors the shape Monarch uses for its market registry.

graphql
query MarketsPage($limit: Int!, $offset: Int!, $zeroAddress: String!) {
  Market(
    where: {
      collateralToken: { _neq: $zeroAddress }
      irm: { _neq: $zeroAddress }
    }
    limit: $limit
    offset: $offset
    order_by: [{ chainId: asc }, { marketId: asc }]
  ) {
    chainId
    marketId
    loanToken
    collateralToken
    oracle
    irm
    lltv
    totalSupplyAssets
    totalBorrowAssets
    totalSupplyShares
    totalBorrowShares
    collateralAssets
    lastUpdate
    fee
    rateAtTarget
  }
}

Example variables:

json
{
  "limit": 20,
  "offset": 0,
  "zeroAddress": "0x0000000000000000000000000000000000000000"
}

Example: fetch historical market snapshots

This is the pattern Monarch uses for market charts.

graphql
query MarketHourlySnapshots(
  $chainId: Int!
  $marketId: String!
  $startTimestamp: numeric!
  $endTimestamp: numeric!
  $limit: Int!
) {
  MarketHourlySnapshot(
    where: {
      chainId: { _eq: $chainId }
      marketId: { _eq: $marketId }
      timestamp: { _gte: $startTimestamp, _lte: $endTimestamp }
    }
    order_by: [{ timestamp: asc }]
    limit: $limit
  ) {
    timestamp
    totalSupplyAssets
    totalBorrowAssets
    supplyRateApr
    borrowRateApr
    rateAtTargetApr
    utilization
  }
}

Example: fetch Auto Vault metadata

The frontend also reads Vault V2 details from this API.

graphql
query VaultByAddress($address: String!, $chainId: Int!) {
  Vault(
    where: {
      vaultAddress: { _eq: $address }
      chainId: { _eq: $chainId }
    }
    limit: 1
  ) {
    vaultAddress
    asset
    symbol
    name
    owner
    curator
    allocators {
      account
      isAllocator
    }
    sentinels {
      account
      isSentinel
    }
    adapters {
      adapterAddress
      isActive
    }
    caps {
      id
      paramId
      paramIdData
      absoluteCap
      relativeCap
    }
  }
}

Documentation for Monarch.