> ## Documentation Index
> Fetch the complete documentation index at: https://tokenterminal.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> To query the Token Terminal data catalog, read https://tokenterminal.com/docs/catalog/agents-manual.md first. It is the whole catalog as one page: table naming grammar, key columns, partition and cluster rules, units, additivity, and the tables that are documented but not served yet.
> Never query a catalog table on a time bound alone. Also filter its cluster key, which you read from INFORMATION_SCHEMA.COLUMNS; an empty result means the object is a view, whose pruning contract is on its page. Compute is billed to the caller's own Google Cloud project.

# Registry

> Every lending market and the reserves inside each one.

The identity tables behind every lending figure. Every fact and metric joins to one of them, and [Coverage](https://tokenterminal.com/docs/catalog/lending.md) introduces each grain.

## Tables

**Projects**

One row per project in the catalog.

<table>
  <thead>
    <tr>
      <th width="230">Column</th>
      <th width="120">Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`project_id`</td><td>STRING</td><td>The project, such as `aave`.</td></tr>
    <tr><td>`slug`</td><td>STRING</td><td>The project's key in Token Terminal page URLs. It differs from `project_id` where the page URL is hyphenated (`redstone-chain` for `redstonechain`).</td></tr>
    <tr><td>`url`</td><td>STRING</td><td>The project's page on the Token Terminal Explorer.</td></tr>
    <tr><td>`name`</td><td>STRING</td><td>Display name.</td></tr>
    <tr><td>`symbol`</td><td>STRING</td><td>Ticker of the project's token, where it has one.</td></tr>
    <tr><td>`logo`</td><td>STRING</td><td>Public URL of the project logo, a PNG. Its `?logo_hash=` suffix changes whenever the image does. Null for a project whose image was never uploaded.</td></tr>
    <tr><td>`description`</td><td>STRUCT</td><td>The project copy: `what` the project is, `who` it serves and `how` it works.</td></tr>
    <tr><td>`links`</td><td>ARRAY\<STRUCT></td><td>The project's links as `type` and `url` pairs (website, x, docs, github). `type` is the label as written, so `twitter` and `x` both occur.</td></tr>
    <tr><td>`market_sectors`</td><td>ARRAY\<STRING></td><td>Every market sector the project belongs to, as tag ids, primary first. Unnesting it yields one row per sector.</td></tr>
    <tr><td>`primary_market_sector`</td><td>STRING</td><td>The market sector the project is listed under: the first element of `market_sectors`. One value per row.</td></tr>
    <tr><td>`listing_date`</td><td>TIMESTAMP</td><td>When the project was listed on Token Terminal.</td></tr>
    <tr><td>`coingecko_id`</td><td>STRING</td><td>The project token's CoinGecko id.</td></tr>
    <tr><td>`coinmarketcap_id`</td><td>STRING</td><td>The project token's CoinMarketCap id.</td></tr>
  </tbody>
</table>

**Apps**

One row per app in the catalog.

<table>
  <thead>
    <tr>
      <th width="230">Column</th>
      <th width="120">Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr><td>`app_id`</td><td>STRING</td><td>The app, such as `aave-v3`.</td></tr>
    <tr><td>`project_id`</td><td>STRING</td><td>The project operating it.</td></tr>
    <tr><td>`name`</td><td>STRING</td><td>Display name.</td></tr>
    <tr><td>`market_sectors`</td><td>ARRAY\<STRING></td><td>Every sector the app is tagged with.</td></tr>
    <tr><td>`primary_market_sector`</td><td>STRING</td><td>The first of those, for grouping.</td></tr>
    <tr><td>`created_at`</td><td>TIMESTAMP</td><td>When the app was added.</td></tr>
  </tbody>
</table>

**Markets**

One row per lending market on one chain.

<table>
  <thead>
    <tr>
      <th width="280">Column</th>
      <th width="130">Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`lending_market_id`</td>
      <td>`STRING`</td>
      <td>Market key, formatted `{lending_market}-{chain_id}`.</td>
    </tr>

    <tr>
      <td>`app_id`</td>
      <td>`STRING`</td>
      <td>App operating the market, such as `aave-v3` or `morpho-blue`. Joins `dimensions.apps`.</td>
    </tr>

    <tr>
      <td>`chain_id`</td>
      <td>`STRING`</td>
      <td>Chain the market lives on.</td>
    </tr>

    <tr>
      <td>`project_id`</td>
      <td>`STRING`</td>
      <td>Project behind the app. Joins `dimensions.projects`.</td>
    </tr>

    <tr>
      <td>`lending_market`</td>
      <td>`STRING`</td>
      <td>The protocol's own key for the market: the pool contract address on pool lenders, the market hash on Morpho Blue.</td>
    </tr>

    <tr>
      <td>`lending_market_contract_address`</td>
      <td>`STRING`</td>
      <td>The deployed contract the market runs on. Matches `lending_market` on pool lenders; every Morpho Blue market on a chain shares one singleton contract.</td>
    </tr>

    <tr>
      <td>`lending_market_name`</td>
      <td>`STRING`</td>
      <td>Readable name of the market, such as `Core` or `Morpho Blue: cbBTC/USDC 86%`. A label, not a key.</td>
    </tr>
  </tbody>
</table>

**Reserves**

One row per reserve, one asset inside one market. An Aave pool lists one reserve per underlying token and a Morpho Blue market exactly two, the loan side and the collateral side; where a pool lists the same token twice, the key is the protocol's listing rather than the token.

<table>
  <thead>
    <tr>
      <th width="280">Column</th>
      <th width="130">Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`lending_market_reserve_id`</td>
      <td>`STRING`</td>
      <td>Reserve key, formatted `{lending_market}-{lending_market_reserve}-{chain_id}`.</td>
    </tr>

    <tr>
      <td>`lending_market_id`</td>
      <td>`STRING`</td>
      <td>Market the reserve belongs to. Joins `dimensions.lending_markets`.</td>
    </tr>

    <tr>
      <td>`app_id`</td>
      <td>`STRING`</td>
      <td>App operating the market. Joins `dimensions.apps`.</td>
    </tr>

    <tr>
      <td>`chain_id`</td>
      <td>`STRING`</td>
      <td>Chain the market lives on.</td>
    </tr>

    <tr>
      <td>`project_id`</td>
      <td>`STRING`</td>
      <td>Project behind the app. Joins `dimensions.projects`.</td>
    </tr>

    <tr>
      <td>`lending_market`</td>
      <td>`STRING`</td>
      <td>The protocol's own key for the market, copied from the market row.</td>
    </tr>

    <tr>
      <td>`lending_market_contract_address`</td>
      <td>`STRING`</td>
      <td>The deployed contract the market runs on, copied from the market row.</td>
    </tr>

    <tr>
      <td>`lending_market_name`</td>
      <td>`STRING`</td>
      <td>Readable name of the market, copied from the market row.</td>
    </tr>

    <tr>
      <td>`lending_market_reserve`</td>
      <td>`STRING`</td>
      <td>The protocol's own key for the reserve inside its market: the underlying token address on Aave-style pools, `loan` or `collateral` on Morpho Blue, the numeric reserve id on Aave v4.</td>
    </tr>

    <tr>
      <td>`lending_market_reserve_name`</td>
      <td>`STRING`</td>
      <td>Readable name: the market name and the token symbol, such as `Core: WETH`. A label, not a key.</td>
    </tr>

    <tr>
      <td>`token_id`</td>
      <td>`STRING`</td>
      <td>Key of the underlying token in `dimensions.tokens`, formatted `{token_address}-{chain_id}`.</td>
    </tr>

    <tr>
      <td>`token_address`</td>
      <td>`STRING`</td>
      <td>Address of the underlying token contract.</td>
    </tr>

    <tr>
      <td>`token_symbol`</td>
      <td>`STRING`</td>
      <td>Ticker symbol of the underlying token.</td>
    </tr>
  </tbody>
</table>

## Sample queries

**Markets per chain**

A project can run several apps and each app several markets on a chain, so the count is per app and chain together.

```sql theme={null}
select
    chain_id,
    app_id,
    count(*) as markets
from `dimensions.lending_markets`
where project_id = 'aave'
group by chain_id, app_id
order by markets desc
```

**Markets in one app**

`lending_market_id` is the key every lending fact and metric joins on. `lending_market_contract_address` is what to look up onchain.

```sql theme={null}
select
    lending_market_id,
    lending_market_name,
    chain_id,
    lending_market_contract_address
from `dimensions.lending_markets`
where app_id = 'aave-v3'
order by chain_id, lending_market_name
```

**Reserves of one market**

`lending_market_reserve` is the protocol's own key for the listing and `lending_market_reserve_id` the catalog key built from it.

```sql theme={null}
select
    lending_market_reserve_id,
    lending_market_reserve,
    token_symbol,
    token_address
from `dimensions.lending_market_reserves`
where lending_market_id = '0xc13e21b648a5ee794902342038ff3adab66be987-ethereum'
order by token_symbol
```

**Where one token is listed**

`token_address` is the underlying token, not the receipt token an app issues against it.

```sql theme={null}
select
    app_id,
    chain_id,
    lending_market_id,
    lending_market_name,
    lending_market_reserve
from `dimensions.lending_market_reserves`
where token_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
  and chain_id = 'ethereum'
order by app_id, lending_market_name
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.