> ## 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.

# Lending

> The lending markets deployed on Gnosis and the asset each one lends.

<Info>
  **In progress.** This vertical is on the way. [Contact us](mailto:sales@tokenterminal.xyz) if you are interested in this dataset. We want to hear more about your use case!
</Info>

A lending protocol lets users deposit one token to earn interest and borrow another against it. The unit it works in is a market: a pool that takes deposits and lends them out. The assets inside a market are its reserves. [`dimensions.lending_markets`](/docs/catalog/lending/registry) lists the Gnosis markets with `chain_id = 'gnosis'`. The reserves inside one market share collateral, so a deposit in one can back a loan in another.

The lending facts land keyed to these markets, one row per event:

* [Deposits](/docs/catalog/lending/deposits) **In progress**
* [Withdrawals](/docs/catalog/lending/withdrawals) **In progress**
* [Borrows](/docs/catalog/lending/borrows) **In progress**
* [Repayments](/docs/catalog/lending/repayments) **In progress**
* [Liquidations](/docs/catalog/lending/liquidations) **In progress**
* [Flash loans](/docs/catalog/lending/flash-loans) **In progress**
* [Interest rates](/docs/catalog/lending/interest-rates) **In progress**

Every column is documented at [Lending](/docs/catalog/lending/index).

## Sample queries

<Tabs>
  <Tab title="Markets per app">
    **Count Gnosis markets by the app that runs them.**

    ```sql theme={null}
    select
        app_id,
        count(*) as markets
    from `dimensions.lending_markets`
    where chain_id = 'gnosis'
    group by app_id
    order by markets desc
    ```
  </Tab>

  <Tab title="Markets one app runs">
    **List the markets one app runs on Gnosis.** `lending_market_address` is the market's own contract.

    ```sql theme={null}
    select
        lending_market_id,
        lending_market_name,
        lending_market_address
    from `dimensions.lending_markets`
    where chain_id = 'gnosis'
      and app_id = 'aave-v4'
    order by lending_market_name
    ```
  </Tab>
</Tabs>
