# Lending

Key Tables:

* **Pools**: Contains information about different lending pools, including the token types, interest rates, and liquidity.
* **Position Snapshot**: Snapshot of user positions in lending pools, including the amounts borrowed and supplied.
* **Pool Snapshot**: Tracks the state of the pool over time, including Total Value Locked, fees earned, and interest rates.
* **Events**: Tracks lending events like deposits, withdrawals, borrowing, and repayments.
* **Liquidations**: Tracks liquidation events.

{% tabs %}
{% tab title="Pools" %}

| Property                   | Description                                                           | Type   |
| -------------------------- | --------------------------------------------------------------------- | ------ |
| chain\_id                  | The standard id of the chain.                                         | number |
| creation\_block\_number    | The block this pool was created in.                                   | number |
| timestamp                  | The timestamp of the block that this pool was created in.             | number |
| underlying\_token\_address | The contract address of the underlying token.                         | string |
| underlying\_token\_symbol  | The symbol of the underlying token.                                   | string |
| receipt\_token\_address    | The contract address of the receipt token.                            | string |
| receipt\_token\_symbol     | The symbol of the receipt token.                                      | string |
| pool\_address              | The contract address of the pool.                                     | string |
| pool\_type                 | The type of the pool (collateral\_only, isolated, supply\_pool, cdp). | string |
| {% endtab %}               |                                                                       |        |

{% tab title="Position Snapshot" %}

| Property                   | Description                                                                                                       | Type   |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp                  | The timestamp of the snapshot.                                                                                    | number |
| block\_date                | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots). | date   |
| chain\_id                  | The standard id of the chain.                                                                                     | number |
| pool\_address              | The contract address of the pool.                                                                                 | string |
| underlying\_token\_address | The contract address of the underlying token.                                                                     | string |
| underlying\_token\_symbol  | The symbol of the underlying token.                                                                               | string |
| user\_address              | The address of the user who has the position.                                                                     | string |
| supplied\_amount           | The amount supplied by the user in the underlying token, decimal normalized.                                      | number |
| supplied\_amount\_usd      | (Optional) The supplied amount in USD.                                                                            | number |
| borrowed\_amount           | The amount borrowed by the user in the underlying token, decimal normalized.                                      | number |
| borrowed\_amount\_usd      | (Optional) The borrowed amount in USD.                                                                            | number |
| collateral\_amount         | (Optional) The amount of collateral-only tokens of this asset, decimal normalized.                                | number |
| collateral\_amount\_usd    | (Optional) The amount of collateral-only tokens in USD.                                                           | number |
| {% endtab %}               |                                                                                                                   |        |

{% tab title="Pool Snapshot" %}

| Property                      | Description                                                                                                                                                | Type   |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp                     | The timestamp of the snapshot.                                                                                                                             | number |
| block\_date                   | The timestamp truncated (ie, YYYY-MM-DD format for daily snapshots and YYYY-MM-DD HH:00:00 for hourly snapshots).                                          | date   |
| chain\_id                     | The standard id of the chain.                                                                                                                              | number |
| pool\_address                 | The contract address of the pool.                                                                                                                          | string |
| underlying\_token\_address    | The contract address of the underlying token.                                                                                                              | string |
| underlying\_token\_symbol     | The symbol of the underlying token.                                                                                                                        | string |
| underlying\_token\_price\_usd | (Optional) The token price of the underlying asset in USD.                                                                                                 | number |
| available\_amount             | The amount of token's available to borrow (liquidity or net supply or supply - borrow).                                                                    | number |
| available\_amount\_usd        | (Optional) The available amount of token's in this pool in USD.                                                                                            | number |
| supplied\_amount              | The total amount of the underlying token supplied in this pool, decimal normalized.                                                                        | number |
| supplied\_amount\_usd         | (Optional) The supplied amount in USD.                                                                                                                     | number |
| collateral\_amount            | (Optional) The amount of collateral only tokens in this pool.                                                                                              | number |
| collateral\_amount\_usd       | (Optional) The amount of collateral only tokens in the pool.                                                                                               | number |
| collateral\_factor            | The collateral factor of the pool (defined as a decimal percentage, between 0-100).                                                                        | number |
| supply\_index                 | The supply index of the pool.                                                                                                                              | number |
| supply\_apr                   | The current annual percentage rate for supplied amount, as a decimal percentage.                                                                           | number |
| borrowed\_amount              | The amount of underlying tokens borrowed from this pool in the underlying token, decimal normalized.                                                       | number |
| borrowed\_amount\_usd         | (Optional) The borrowed amount in USD.                                                                                                                     | number |
| borrow\_index                 | The borrow index of the pool.                                                                                                                              | number |
| borrow\_apr                   | The current annual percentage rate for borrow, as a decimal percentage.                                                                                    | number |
| total\_fees\_usd              | (Optional) The total revenue or fees accrued in this pool during the given snapshot period (ie, user\_fees\_usd + protocol\_fees\_usd = total\_fees\_usd). | number |
| user\_fees\_usd               | (Optional) The portion of total revenue or fees accrued to users of the protocol during the given snapshot period.                                         | number |
| protocol\_fees\_usd           | (Optional) The portion of total revenue or fees accrued to protocol during the given snapshot period.                                                      | number |
| {% endtab %}                  |                                                                                                                                                            |        |

{% tab title="Events" %}

| Property          | Description                                                                                                                              | Type   |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| timestamp         | The timestamp of the transaction.                                                                                                        | number |
| chain\_id         | The standard id of the chain.                                                                                                            | number |
| block\_number     | The block number of the trade.                                                                                                           | number |
| log\_index        | The event log. For transactions that don't emit event, create arbitrary index starting from 0.                                           | number |
| transaction\_hash | The hash of the transaction.                                                                                                             | string |
| user\_address     | The address that initiates the transaction (ie, the transaction signer).                                                                 | string |
| taker\_address    | The address that receives the output of the event (ie, account that receives aTokens in an Aave Deposit).                                | string |
| pool\_address     | The contract address of the pool.                                                                                                        | string |
| token\_address    | The address of the underlying token that was interacted with (ie, USDC and not aUSDC in Aave).                                           | string |
| amount            | The amount of token\_address transacted, decimal normalized.                                                                             | number |
| amount\_usd       | The amount of token\_address transacted, in USD.                                                                                         | number |
| event\_type       | The type of lending event, corresponds to the action taken by the user (ie, deposit, withdrawal, borrow, repay, liquidation, flashloan). | string |
| {% endtab %}      |                                                                                                                                          |        |

{% tab title="Liquidations" %}

| Property            | Description                                                                                             | Type   |
| ------------------- | ------------------------------------------------------------------------------------------------------- | ------ |
| timestamp           | The timestamp of the transaction.                                                                       | number |
| chain\_id           | The standard id of the chain.                                                                           | number |
| block\_number       | The block number of the trade.                                                                          | number |
| log\_index          | The event log. For transactions that don't emit event, create arbitrary index starting from 0.          | number |
| transaction\_hash   | The hash of the transaction.                                                                            | string |
| liquidator\_address | The address that initiates the liquidation.                                                             | string |
| user\_address       | The address that was liquidated.                                                                        | string |
| pool\_address       | The contract address of the pool.                                                                       | string |
| token\_address      | The address of the underlying token that was repaid by the liquidator (ie, USDC and not aUSDC in Aave). | string |
| amount              | The amount of token\_address transacted, decimal normalized.                                            | number |
| amount\_usd         | The amount of token\_address transacted, in USD.                                                        | number |
| profit\_usd         | The amount of profit the liquidator made from liquidating user\_address (can be negative).              | number |
| {% endtab %}        |                                                                                                         |        |
| {% endtabs %}       |                                                                                                         |        |
