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

# Lending

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

A lending protocol lets users deposit one token to earn interest and borrow another against it. The unit it works in is a market: one pool crossed with one asset that can be supplied and borrowed. [`dimensions.lending_markets`](/docs/catalog/lending/registry) lists the Avalanche markets with `chain_id = 'avalanche'`; a pool groups markets that share collateral, so a deposit in one market 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 by pool">
    **Count Avalanche markets by protocol version and pool.**

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

  <Tab title="Assets one version lends">
    **List the assets one version lends on Avalanche.** `underlying_token_address` is the token being supplied and borrowed; `lending_market_address` is the market's own contract.

    ```sql theme={null}
    select
        underlying_symbol,
        market_name,
        underlying_token_address,
        lending_market_address
    from `dimensions.lending_markets`
    where chain_id = 'avalanche'
      and protocol_id = 'aave-v3'
    order by underlying_symbol
    ```
  </Tab>
</Tabs>
