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

# Aave

> Aave Schema Description and Methodology

This schema contains comprehensive datasets for tracking Aave fundamental data across multiple metrics categories, including lending activity, deposits, loans, revenue streams, treasury, liquidations, and market data.

## Available Tables

Aave data is available in several tables:

* **ez\_metrics**: Main aggregated metrics for the entire Aave protocol
* **ez\_metrics\_by\_chain**: Metrics broken down by blockchain (Ethereum, Arbitrum, Optimism, etc.)
* **ez\_metrics\_by\_token**: Metrics broken down by token (USDC, ETH, AAVE, etc.)

## Table Schema

### Lending Activity Metrics

| Table Name  | Column Name         | Description                                           |
| ----------- | ------------------- | ----------------------------------------------------- |
| ez\_metrics | lending\_deposits   | The total amount of tokens deposited (in USD) on Aave |
| ez\_metrics | lending\_loans      | The total outstanding loans (in USD) on Aave          |
| ez\_metrics | net\_deposits       | Legacy naming for lending\_deposits                   |
| ez\_metrics | outstanding\_supply | Legacy naming for lending\_loans                      |
| ez\_metrics | tvl                 | The total value locked in Aave (deposits - loans)     |

### Fee and Revenue Metrics

| Table Name  | Column Name          | Description                                               |
| ----------- | -------------------- | --------------------------------------------------------- |
| ez\_metrics | fees                 | The total USD value generated from all user-paid fees     |
| ez\_metrics | interest\_rate\_fees | Interest fees paid by borrowers on loans                  |
| ez\_metrics | flashloan\_fees      | Fees generated from flash loans                           |
| ez\_metrics | gho\_fees            | Fees generated from GHO stablecoin operations             |
| ez\_metrics | fees                 | Legacy naming for total fees (interest + flashloan + gho) |

### Revenue Distribution Metrics

| Table Name  | Column Name                                | Description                                                          |
| ----------- | ------------------------------------------ | -------------------------------------------------------------------- |
| ez\_metrics | service\_fee\_allocation                   | Revenue accrued to liquidity providers (deposit revenue + flashloan) |
| ez\_metrics | liquidator\_fee\_allocation                | Revenue allocated to liquidators                                     |
| ez\_metrics | treasury\_fee\_allocation                  | Revenue allocated to Aave treasury (reserve factor + dao + gho)      |
| ez\_metrics | reserve\_factor\_treasury\_fee\_allocation | Portion of interest fees sent to treasury via reserve factor         |
| ez\_metrics | dao\_treasury\_fee\_allocation             | Revenue from DAO trading activities                                  |
| ez\_metrics | gho\_treasury\_fee\_allocation             | Revenue from GHO operations sent to treasury                         |

### Incentives and Expenses

| Table Name  | Column Name           | Description                                               |
| ----------- | --------------------- | --------------------------------------------------------- |
| ez\_metrics | ecosystem\_incentives | Incentives distributed to ecosystem participants          |
| ez\_metrics | safety\_incentives    | Incentives distributed for the safety module              |
| ez\_metrics | token\_incentives     | Total token incentives (ecosystem + safety)               |
| ez\_metrics | total\_expenses       | Total protocol expenses (currently just token incentives) |
| ez\_metrics | protocol\_earnings    | Protocol revenue minus total expenses                     |

### Treasury Metrics

| Table Name  | Column Name             | Description                                               |
| ----------- | ----------------------- | --------------------------------------------------------- |
| ez\_metrics | treasury                | The total USD value in Aave's treasury                    |
| ez\_metrics | treasury\_native        | The USD value of AAVE tokens in the treasury              |
| ez\_metrics | net\_treasury           | The USD value in treasury excluding protocol's own tokens |
| ez\_metrics | treasury\_value         | Legacy naming for treasury                                |
| ez\_metrics | treasury\_value\_native | Legacy naming for treasury\_native                        |
| ez\_metrics | net\_treasury\_value    | Legacy naming for net\_treasury                           |

### Market and Token Metrics

| Table Name  | Column Name                  | Description                                           |
| ----------- | ---------------------------- | ----------------------------------------------------- |
| ez\_metrics | price                        | The price of AAVE token in USD                        |
| ez\_metrics | market\_cap                  | The market cap of AAVE token in USD                   |
| ez\_metrics | fdmc                         | The fully diluted market cap of AAVE token in USD     |
| ez\_metrics | token\_volume                | The trading volume of AAVE token in USD               |
| ez\_metrics | token\_turnover\_circulating | The turnover of AAVE based on circulating supply      |
| ez\_metrics | token\_turnover\_fdv         | The turnover of AAVE based on fully diluted valuation |
| ez\_metrics | token\_holder\_count         | The number of unique AAVE token holders               |
| ez\_metrics | h24\_volume                  | The 24-hour trading volume of AAVE (legacy naming)    |

### Chain-specific Metrics (ez\_metrics\_by\_chain)

The `ez_metrics_by_chain` table provides the same metrics as the main table but broken down by blockchain network:

| Column Name                 | Description                                         |
| --------------------------- | --------------------------------------------------- |
| date                        | The date of the recorded metrics                    |
| chain                       | The blockchain (Ethereum, Arbitrum, Optimism, etc.) |
| lending\_deposits           | Total deposits on this chain                        |
| lending\_loans              | Outstanding loans on this chain                     |
| tvl                         | Total value locked on this chain                    |
| fees                        | Total protocol revenue on this chain                |
| service\_fee\_allocation    | Revenue to liquidity providers on this chain        |
| liquidator\_fee\_allocation | Revenue to liquidators on this chain                |
| treasury\_fee\_allocation   | Revenue to treasury on this chain                   |
| treasury                    | Treasury value associated with this chain           |
| treasury\_native            | AAVE token value in treasury for this chain         |

### Token-specific Metrics (ez\_metrics\_by\_token)

The `ez_metrics_by_token` table breaks down metrics by individual tokens:

| Column Name                         | Description                                     |
| ----------------------------------- | ----------------------------------------------- |
| date                                | The date of the recorded metrics                |
| chain                               | The blockchain where the token is used          |
| token\_address                      | The contract address of the token               |
| lending\_deposits                   | Deposits of this specific token (USD)           |
| lending\_deposits\_native           | Deposits of this token in native units          |
| lending\_loans                      | Loans of this specific token (USD)              |
| lending\_loans\_native              | Loans of this token in native units             |
| tvl                                 | TVL for this token (USD)                        |
| tvl\_native                         | TVL for this token in native units              |
| fees                                | Revenue generated by this token (USD)           |
| fees\_native                        | Revenue generated by this token in native units |
| service\_fee\_allocation            | Revenue to liquidity providers from this token  |
| service\_fee\_allocation\_native    | Revenue to LPs in native token units            |
| liquidator\_fee\_allocation         | Revenue to liquidators from this token          |
| liquidator\_fee\_allocation\_native | Revenue to liquidators in native token units    |
| treasury\_fee\_allocation           | Revenue to treasury from this token             |
| treasury\_fee\_allocation\_native   | Revenue to treasury in native token units       |
| treasury                            | Treasury holdings of this token (USD)           |
| treasury\_native                    | Treasury holdings in native token units         |

## Sample Queries

### Basic Protocol Activity Query

```sql theme={null}
-- Pull fundamental lending data for Aave
SELECT
    date,
    lending_deposits,
    lending_loans,
    tvl,
    price
FROM
    art_share.aave.ez_metrics
WHERE
    date >= DATEADD(month, -3, CURRENT_DATE())
ORDER BY
    date ASC
```

### Revenue Analysis

```sql theme={null}
-- Analyze Aave revenue streams
SELECT
    date,
    fees,
    interest_rate_fees,
    flashloan_fees,
    gho_fees,
    service_fee_allocation,
    liquidator_fee_allocation,
    treasury_fee_allocation
FROM
    art_share.aave.ez_metrics
WHERE
    date >= DATEADD(month, -3, CURRENT_DATE())
ORDER BY
    date ASC
```

### Revenue Distribution Analysis

```sql theme={null}
-- Analyze how Aave's revenue is distributed
SELECT
    date,
    fees,
    service_fee_allocation,
    liquidator_fee_allocation,
    treasury_fee_allocation,
    service_fee_allocation / fees * 100 as lp_percentage,
    liquidator_fee_allocation / fees * 100 as liquidator_percentage,
    treasury_fee_allocation / fees * 100 as treasury_percentage
FROM
    art_share.aave.ez_metrics
WHERE
    date >= DATEADD(month, -3, CURRENT_DATE())
ORDER BY
    date ASC
```

### Treasury Analysis

```sql theme={null}
-- Track Aave treasury composition
SELECT
    date,
    treasury,
    treasury_native,
    net_treasury,
    treasury_native / treasury * 100 as aave_token_percentage,
    token_incentives,
    protocol_earnings
FROM
    art_share.aave.ez_metrics
WHERE
    date >= DATEADD(month, -3, CURRENT_DATE())
ORDER BY
    date ASC
```

### Cross-Chain Comparison

```sql theme={null}
-- Compare Aave metrics across different blockchains
SELECT
    date,
    chain,
    lending_deposits,
    lending_loans,
    tvl,
    fees
FROM
    art_share.aave.ez_metrics_by_chain
WHERE
    date >= DATEADD(month, -1, CURRENT_DATE())
ORDER BY
    chain, date ASC
```

### Token Analysis

```sql theme={null}
-- Analyze the performance of specific tokens on Aave
SELECT
    date,
    chain,
    token_address,
    lending_deposits,
    lending_loans,
    fees,
    service_fee_allocation
FROM
    art_share.aave.ez_metrics_by_token
WHERE
    date = DATEADD(day, -1, CURRENT_DATE())
    AND token_address IN (
        '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', -- USDC
        '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', -- WETH
        '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9'  -- AAVE
    )
ORDER BY
    fees DESC
```

### GHO Stablecoin Analysis

```sql theme={null}
-- Track Aave's GHO stablecoin revenue
SELECT
    date,
    gho_fees,
    gho_treasury_fee_allocation,
    gho_fees / fees * 100 as gho_revenue_percentage
FROM
    art_share.aave.ez_metrics
WHERE
    date >= '2023-07-01'  -- Approximate GHO launch date
    AND date <= CURRENT_DATE()
ORDER BY
    date ASC
```

### Protocol Economics Analysis

```sql theme={null}
-- Analyze Aave protocol economics
SELECT
    date,
    lending_deposits,
    lending_loans,
    lending_loans / lending_deposits * 100 as utilization_rate,
    fees,
    fees / lending_loans * 365 * 100 as annualized_revenue_rate,
    token_incentives,
    protocol_earnings,
    price
FROM
    art_share.aave.ez_metrics
WHERE
    date >= DATEADD(month, -3, CURRENT_DATE())
ORDER BY
    date ASC
```
