r/thegraph • • 5h ago

Blogposts How to read Lido Lend with a few GraphQL queries

Post image
3 Upvotes

Lido Lend has been live since November 30, and the official Lido subgraph still covers staking and DAO data only. Here is how to read the new market, and how to line it up with staking APR and the vote that approved it.

Lido Lend went live on November 30. It is Lido DAO's Morpho Blue fork on Ethereum: isolated markets, per-market controllers, and a settle path that lets a lender exit by canceling a borrower's debt at the oracle price. The first market is WETH/wstETH, with 98% LLTV and a 5,000 WETH supply cap.

The official Lido subgraph already indexes staking, oracle reports, and DAO governance, and it gets a few million queries a month. It does not index Lido Lend. I built a subgraph that does. Here are a few queries you can run today, with the numbers I got this afternoon (Friday, December 4, about 12:18 PM ET).

Query it on The Graph Explorer: https://thegraph.com/explorer/subgraphs/CYN2yvoiGyJjCrJV3EgTVtWK58MZ31rYhxojeYtdXoYR?view=Query&chain=arbitrum-one

1. Market state

{
  markets {
    loanToken { symbol }
    collateralToken { symbol }
    lltvBD
    feeBD
    totalSupply
    totalBorrow
    totalCollateralBD
    availableLiquidity
    utilization
    borrowAPY
    supplyAPY
    oraclePriceBD
    totalCollateralValue
    lastUpdate
    supplyCap
    activeSupplierCount
    activeBorrowerCount
    settlementEnabled
    settlementCount
    liquidationCount
    controller { frozen paused minActivationDelay }
  }
}

As of 12:17 PM ET on December 4, the WETH/wstETH market had 1,020.29 WETH supplied and 513.50 WETH borrowed, so utilization was 50.3%. There were 797.39 wstETH of collateral, valued at 997.40 WETH at the market oracle (1 wstETH = 1.2508 WETH). The borrow APY was 0.766% and the supply APY was 0.347%. About 20% of the 5,000 WETH supply cap was used. Settlement is enabled, the controller is not paused or frozen, and so far there are 4 active suppliers, 6 active borrowers, 1 settlement, and no liquidations.

One thing to know: Morpho only accrues interest when the market is touched, so totals, rates, and health factors are exact as of that last update, not necessarily the current block.

2. Riskiest open borrowers

{
  positions(
    where: { borrowShares_gt: "0" }
    orderBy: healthFactor
    orderDirection: asc
    first: 10
  ) {
    account { id }
    collateralBD
    borrow
    collateralValue
    ltv
    healthFactor
    liquidationPriceDrop
    lastUpdatedTimestamp
  }
}

Health factor is lltv * collateralValue / borrow. Below 1 is liquidatable. These six accounts currently have debt (values as of each position's last update):

  • 0x83dd…8157: 49.50 WETH debt against 41.00 wstETH (~51.28 WETH). LTV 96.5%, health factor 1.015, liquidatable after a 1.5% collateral price drop. Last updated 12:17 PM ET.
  • 0xa90f…d950: 17.00 WETH against 14.27 wstETH (~17.85 WETH). LTV 95.2%, health factor 1.029.
  • 0x8dc7…f3c7: 11.00 WETH against 10.07 wstETH (~12.60 WETH). LTV 87.3%, health factor 1.123.
  • 0x569d…01f9: 76.00 WETH against 70.00 wstETH (~87.56 WETH). LTV 86.8%, health factor 1.129.
  • 0xa02f…03f9: 80.00 WETH against 75.67 wstETH (~94.65 WETH). LTV 84.5%, health factor 1.160.
  • 0x0c88…b63e: 280.00 WETH against 459.41 wstETH (~574.65 WETH). LTV 48.7%, health factor 2.011.

The tightest book is that first one, only a thin cushion above 98% LLTV. The largest loan is in much better shape.

3. Daily and hourly history

{
  marketDailySnapshots(orderBy: day, orderDirection: desc, first: 7) {
    date
    totalSupply
    totalBorrow
    utilization
    borrowAPY
    supplyAPY
    dailySupplied
    dailyWithdrawn
    dailyBorrowed
    dailyRepaid
    dailyInterest
    dailySettledDebt
    activeBorrowerCount
    eventCount
  }
}

totalSupply, totalBorrow, utilization, and the APY fields are already in token units or fractions. The daily* volume fields are raw wei, so divide by 1e18 for WETH. End-of-day snapshots so far (UTC days):

  • December 4: 1,020.29 WETH supplied, 513.50 borrowed, 50.3% utilization, 0.766% borrow APY. 490.6 WETH was borrowed today, 4.35 WETH withdrawn, 1 WETH repaid. 6 active borrowers, 37 events.
  • December 3: 1,024.57 supplied, 23.90 borrowed, 2.3% utilization, 0.346% borrow APY. 23.9 WETH borrowed, 24.57 WETH supplied. 1 active borrower.
  • December 2: 1,000.00 supplied, 0 borrowed. That was the day the first 1,000 WETH landed.
  • December 1: almost idle (a few thousandths of a WETH).
  • November 30, the first day: 5 WETH borrowed, 3 WETH repaid, and 2 WETH of debt settled.

Most of the borrowing is from this morning. The same flows are also rolled up hourly. MarketStats is a timeseries aggregation, and because the type name is both singular and plural, the list field is marketStats_collection. Pass interval: hour or interval: day. The timestamp values are microseconds, so divide by 1e6 for a unix time. Volumes on this field are already in token units.

{
  marketStats_collection(
    interval: hour
    where: { market: "0xe4af8961b4e5a779b85d8c461be1007e4b78a7933976e0a5f23121682020de29" }
    first: 12
    orderBy: timestamp
    orderDirection: desc
  ) {
    timestamp
    totalSupply
    totalBorrow
    utilization
    borrowAPY
    minBorrowAPY
    maxBorrowAPY
    supplyAPY
    borrowed
    repaid
    supplied
    withdrawn
    interest
    eventCount
  }
}

A few completed hours from this morning (each row is the state at the end of that hour):

  • 9:00 AM ET: 356 WETH was borrowed in the hour (the 280 and 76 WETH loans). Utilization jumped from 11.5% to 46.4%, and borrow APY from 0.40% to 0.73%.
  • 10:00 AM ET: another 17 WETH borrowed. Utilization 48.0%, borrow APY 0.75%.
  • 11:00 AM ET: 12 WETH borrowed and 1 WETH repaid. Utilization 49.1%, borrow APY 0.76%.

The 12:00 PM ET hour is still open, so it is not in the collection yet. The live market state above already includes the 12.6 WETH borrow at 12:17 PM ET.

4. Settlements, liquidations, and recent borrows

{
  settlements(orderBy: timestamp, orderDirection: desc, first: 5) {
    timestamp
    lender { id }
    borrower { id }
    debtCanceled
    collateralSeized
    impliedPrice
    transactionHash
  }
  liquidations(orderBy: timestamp, orderDirection: desc, first: 5) {
    timestamp
    borrower { id }
    repaid
    seized
    badDebt
  }
  borrows(orderBy: timestamp, orderDirection: desc, first: 8) {
    timestamp
    account { id }
    amount
    transactionHash
  }
}

There has been one settlement and no liquidations. On November 30 at 11:41 AM ET, the lender vault lendWETHwstETH (0xd876…a056) burned supply to cancel 2.00 WETH of debt from 0x165f…46cc and received 1.599 wstETH. The implied price was 1.2505 WETH per wstETH, in line with the oracle.

The recent borrow list is already real size: 280, 80, 76, 17, 13, 12.6, and 12 WETH, almost all from today.

5. Line this up with the official Lido subgraph

Lido Lend's oracle is wstETH's stEthPerToken and treats stETH as 1 ETH. That means collateral value, and therefore health factors, rise when Lido's share rate rises. The official Lido subgraph is where you get that share rate, the staking APR, and the DAO activity that approved the market.

Official Lido subgraph on Explorer: https://thegraph.com/explorer/subgraphs/Sxx812XgeKyzQPaBpR5YZWmGV5fZuBaPdh7DFhzSwiQ?view=Query&chain=arbitrum-one

Staking APR and the wstETH share rate:

{
  totalRewards(first: 7, orderBy: blockTime, orderDirection: desc) {
    blockTime
    apr
    timeElapsed
    totalPooledEtherAfter
    totalSharesAfter
    transactionHash
  }
}

apr here is in percent, not a fraction. This morning's oracle report (7:22 AM ET, December 4) put user staking APR at 2.78%. The 7-day average is 2.68%, the 14-day average is 2.51% (the last two weeks ranged from 2.25% to 4.39%). After that report, 1 wstETH is 1.250923 stETH (totalPooledEtherAfter / totalSharesAfter).

The Lido Lend oracle still shows 1.250828. That is not a bug. It only refreshes once per UTC day, on the market's first event, and today's refresh (12:00:23 AM UTC) happened before the 7:22 AM ET report. It matches yesterday's share rate exactly. The next daily refresh should pick up this morning's report.

At today's 0.766% WETH borrow APY, the spread between wstETH staking and borrowing WETH is about 2 percentage points. That is the basic looping carry, and it will move as utilization and staking rewards move. One caveat: because the Lido Lend oracle assumes stETH = 1 ETH, this ignores any stETH/ETH discount.

You can also watch new markets get approved before they go live. Lido Lend itself shows up in the official subgraph's voting and Easy Track data. Aragon vote 207, created November 18 and later executed, added the Lido Lend Easy Track factories, including LidoLendActivateMarket (0x17bb…3fe6). Easy Track motion 1225 used that factory, started November 27, and was enacted November 30 at 4:29 AM ET with no objections — the same minute the WETH/wstETH market was created.

{
  motion(id: "1225") {
    id
    status
    startDate
    enacted_at
    duration
    objectionsAmount
    evmScriptFactory
    transactionHash
  }
  motions(first: 5, orderBy: startDate, orderDirection: desc) {
    id
    status
    startDate
    enacted_at
    evmScriptFactory
  }
  voting(id: "207") {
    index
    metadata
    executed
    blockTime
    transactionHash
  }
}

Motion 1225 is ENACTED, ran for the usual 3-day Easy Track window, and recorded 0 objections. The factory address matches LidoLendActivateMarket from vote 207. You can also view motion 1225 and vote 207 on Lido's own UIs. As of this morning there were also five newer motions (1226–1230) still marked ACTIVE.

What else the Lido Lend subgraph gives you

  • The lendWETHwstETH vault: right now about 20.29 WETH of assets, share price 1.000003, 8 holders. Tiny vault rebalances are tagged isDust, so you can filter them out.
  • Controller policy: supply cap, pause and freeze, and collateral activation delays (the minimum delay is currently 2 hours).
  • Per-position activation buckets (activating, dust, already-active collateral) and guardian strikes or bans.
  • Interest accruals, IRM rate updates, and flash loans as they happen.

Repo, with schema and more example queries: github.com/PaulieB14/lido-lend-subgraph

Lido's own docs for the protocol: docs.lido.fi/lend

If you would rather not write GraphQL, Graph Advocate also exposes this as a small x402 API: /lido-lend is $0.05 and /lido-lend/position is $0.01 on graphadvocate.com.