# Interest rates, borrowed and deposited amounts

## What is this endpoint for?

This endpoint provides information about lending pools. It shows data such as how many tokens has been deposited and borrowed, as well as the interest rates for lending and borrowing at each block.

### Endpoint

{% code overflow="wrap" %}

```http
https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots
```

{% endcode %}

### Parameters

<table><thead><tr><th>Parameter</th><th width="88" data-type="checkbox">Mandatory?</th><th width="272">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>blockchain</code></td><td>false</td><td>One or several of the currently supported blockchain. <br><br>Default: <code>ethereum</code>.<br><br>See <a data-mention href="/pages/a2ImeIv5a9wmXExkWX8W">/pages/a2ImeIv5a9wmXExkWX8W</a></td><td><code>ethereum</code></td></tr><tr><td><code>protocol</code></td><td>true</td><td>One or several of the currently supported L&#x26;B protocols.</td><td><code>aav1</code></td></tr><tr><td><code>asset</code></td><td>true</td><td>L&#x26;B events including the requested token. Default: all available tokens.</td><td><code>tusd</code></td></tr><tr><td><code>live</code></td><td>false</td><td>Shows the data as soon as the block is validated. <br><br>(Default: <code>false</code>, in case of block reorganization).</td><td><code>true</code></td></tr><tr><td><code>block_number</code></td><td>false</td><td>Block height.</td><td><code>10795593</code></td></tr><tr><td><code>start_block</code></td><td>false</td><td>Starting block height (inclusive).</td><td><code>129870</code></td></tr><tr><td><code>end_block</code></td><td>false</td><td>Ending block height (inclusive).</td><td><code>130000</code></td></tr><tr><td><code>start_time</code></td><td>false</td><td>Starting time in ISO 8601 (inclusive).</td><td><code>2022-04-01T00:00:00.000Z</code></td></tr><tr><td><code>end_time</code></td><td>false</td><td>Ending time in ISO 8601 (inclusive).</td><td><code>2022-05-01T00:00:00.000Z</code></td></tr><tr><td><code>interval</code></td><td>false</td><td>Interval between each snapshot. The suffixes are s (second), m (minute), h (hour), d (day), b (block), change (whenever a change happens). Default: 1b.</td><td><code>152s</code></td></tr><tr><td><code>sort</code></td><td>false</td><td>Returns the data in ascending or descending order. Default: desc.</td><td><code>ascending</code></td></tr><tr><td><code>page_size</code></td><td>false</td><td>Number of snapshots to return data for. <br><br>(default: <code>100</code>, min: 1, max: <code>1000</code>). <br><br>See <a data-mention href="/pages/mP3amLsYqKTsrRBoblxX">/pages/mP3amLsYqKTsrRBoblxX</a></td><td><code>1000</code></td></tr></tbody></table>

### Fields

| Field                  | Description                                                   | Example                                      |
| ---------------------- | ------------------------------------------------------------- | -------------------------------------------- |
| `blockchain`           | The blockchain on which the transaction happened.             | `ethereum`                                   |
| `block_number`         | The height of the block in which the transaction happened.    | `16025918`                                   |
| `datetime`             | The timestamp of the block in which the transaction happened. | `1669124591`                                 |
| `protocol`             | Code of the L\&B protocol.                                    | `aave/v2`                                    |
| `asset_symbol`         | Symbol of the underlying asset.                               | `crv`                                        |
| `asset_address`        | Address of the underlying asset.                              | `0xd533a949740bb3306d119cc777fa900ba034cd52` |
| `asset_decimals`       | Decimals of the underlying asset.                             | `18`                                         |
| `receipt_symbol`       | Symbol of the receipt asset.                                  | `acrv`                                       |
| `receipt_address`      | Address of the receipt asset.                                 | `0x8dae6cb04688c62d939ed9b68d32bc62e49970b1` |
| `receipt_decimals`     | Decimals of the receipt asset.                                | `18`                                         |
| `total_liquidity`      | The total amount of liquidity for this pool.                  | `1486160`                                    |
| `available_liquidity`  | The total amount of available liquidity for this pool.        | `1279630`                                    |
| `total_borrowed`       | The total amount of tokens borrowed for this pool.            | `206535`                                     |
| `supply_rate`          | The supply rate.                                              | `0.00289186`                                 |
| `stable_borrow_rate`   | The stable borrow rate.                                       | `0.0442648`                                  |
| `variable_borrow_rate` | The variable borrow rate.                                     | `0.0208089`                                  |
| `metadata`             | Metadata specific to each protocol.                           | More information below                       |

### Metadata information

**AAVE v1**

<table><thead><tr><th>Field</th><th width="334">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_borrowed_stable</code></td><td>The total amount of assets borrowed with a stable rate for this pool.</td><td><code>0</code></td></tr><tr><td><code>total_borrowed_variable</code></td><td>The total amount of assets borrowed with a variable rate for this pool.</td><td><code>41872.928778</code></td></tr></tbody></table>

**AAVE v2**

<table><thead><tr><th>Field</th><th width="333">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_borrowed_stable</code></td><td>The total amount of assets borrowed with a stable rate for this pool.</td><td><code>4162389.524515</code></td></tr><tr><td><code>total_borrowed_variable</code></td><td>The total amount of assets borrowed with a variable rate for this pool.</td><td><code>345075360.304631</code></td></tr><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>51387128.92415</code></td></tr></tbody></table>

**Compound**

<table><thead><tr><th>Field</th><th width="288">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>3486037.365878</code></td></tr></tbody></table>

**Cream**

<table><thead><tr><th>Field</th><th width="298">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>total_reserves</code></td><td>Total liquidity - All of the debt tokens supply.</td><td><code>033661.402437</code></td></tr></tbody></table>

**Maker**

<table><thead><tr><th>Field</th><th width="305">Description</th><th>Example</th></tr></thead><tbody><tr><td><code>collateral_ratio</code></td><td>Minimum ratio of collateral before liquidation.</td><td><code>1.5</code></td></tr><tr><td><code>debt_ceiling</code></td><td>Maximum amount of DAI that can be emitted on this type of vault.</td><td><code>2500000</code></td></tr><tr><td><code>debt_floor</code></td><td>Minimum amount of DAI that can be minted for this type of Vault.</td><td><code>2000</code></td></tr></tbody></table>

### Request example

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```url
curl --compressed \
  -H 'Accept: application/json' \
  -H 'X-Api-Key: <client-api-key>' \
  'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots?protocol=aav1&asset=tusd'
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}

```python
##### 1. Import dependencies #####
import requests
import pandas as pd

##### 2. Choose the value of the query's parameters #####
# ---- Required parameters ---- #
blockchain = "ethereum" 
protocol = "aav2"
asset = "tusd"

# ---- Optional parameters ---- #
user_address = None
live = "false"
tx_hash = None
block_number = None
start_block = None
end_block = None
start_time = "2025-03-01T13:00:00Z"
end_time = "2025-03-01T13:10:00Z"
sort = "desc"
page_size = 1000
interval = None

# ---- API key configuration ---- #
api_key = "YOUR_API_KEY"

##### 3. Get the data #####
# ---- Function to run an API call ---- # 
# Get the data in a dataframe --------- # 

def get_kaiko_data(api_key: str, blockchain: str, protocol: str, asset: str, user_address: str, live: str, tx_hash: str, block_number: int, start_block: int, end_block: int, start_time: str, end_time: str, interval: str, sort: str, page_size: int):
    headers = {'Accept': 'application/json', 'X-Api-Key': api_key}
    
    url = f'https://eu.market-api.kaiko.io/v2/data/lending.v1/snapshots'
    params = {
        "blockchain": blockchain,
        "protocol": protocol,
        "asset": asset,
        "user_address": user_address,
        "live": live,
        "tx_hash": tx_hash,
        "block_number": block_number,
        "start_block": start_block,
        "end_block": end_block,
        "start_time": start_time,
        "end_time": end_time,
        "interval": interval,
        "sort": sort,
        "page_size": page_size
    }

    try:
        res = requests.get(url, headers=headers, params=params)
        res.raise_for_status() 
        data = res.json()
        if 'data' not in data:
            print("No data returned.")
            return pd.DataFrame() 
        df = pd.DataFrame(data['data'])

        # Handle pagination with continuation token
        while 'next_url' in data:
            next_url = data['next_url']
            if next_url is None:
                break
            res = requests.get(next_url, headers=headers)
            res.raise_for_status()
            data = res.json()
            if 'data' in data:
                df = pd.concat([df, pd.DataFrame(data['data'])], ignore_index=True)
        return df

    except requests.exceptions.RequestException as e:
        print(f"API request error: {e}")
        return pd.DataFrame() 

# ---- Get the data ---- #
df = get_kaiko_data(api_key=api_key, blockchain=blockchain, protocol=protocol, asset=asset, user_address=user_address, live=live, tx_hash=tx_hash, block_number=block_number, start_block=start_block, end_block=end_block, start_time=start_time, end_time=end_time, interval=interval, sort=sort, page_size=page_size)
print (df)
```

{% endtab %}
{% endtabs %}

### Response example

```json
{
            "blockchain": "ethereum",
            "block_number": "21093894",
            "datetime": 1730477315,
            "market_id": "aave/v1/tusd",
            "protocol": "aav1",
            "asset_symbol": "tusd",
            "asset_address": "0x0000000000085d4780b73119b644ae5ecd22b376",
            "asset_decimals": "18",
            "receipt_symbol": "atusd",
            "receipt_address": "0x4da9b813057d04baef4e5800e36083717b4a0341",
            "receipt_decimals": "18",
            "available_liquidity": 293515.77258708066,
            "total_borrowed": 10897.083558481298,
            "total_liquidity": 304412.85614556196,
            "supply_rate": 0,
            "stable_borrow_rate": 0,
            "variable_borrow_rate": 0,
            "metadata": {
                "total_borrowed_stable": "0",
                "total_borrowed_variable": "10897.083558481297049061"
            }
        },
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kaiko.com/rest-api/data-feeds/level-1-and-level-2-data/level-2-aggregations/interest-rates-borrowed-and-deposited-amounts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
