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

# Loans

> Solana lending loan events (borrows).

The `solana.lending.loans` table contains Solana lending loan events (borrows). This table tracks all borrowing activity across supported lending protocols on Solana (Kamino, MarginFi, Jupiter Lend, and Save).

Use this table to analyze borrowing patterns, track loan volumes, and understand lending activity across different protocols and tokens.

### Table Details

| Property | Value |
| - | - |
| Table Name | `solana.lending.loans` |
| Table Status | Production-Ready |
| Unique Key | `block_timestamp`, `unique_id` |
| Clustering Key(s) | `block_timestamp::date` |

### Table Columns

| Column Name | Data Type | Description |
| - | - | - |
| project | VARCHAR(16777216) | Business name of the protocol being used (e.g. `kamino`, `marginfi`, `jupiter`). |
| protocol | VARCHAR(16777216) | Specific version or variant of the protocol (e.g. `klend`, `marginfi`, `juplend`). |
| lending\_event | VARCHAR(16777216) | Category of lending event. One of: `deposits`, `withdrawals`, `borrows`, `repayments`, `liquidations`. |
| event\_name | VARCHAR(16777216) | Name of the decoded instruction or event that produced this record (e.g. `borrow_obligation_liquidity`, `lending_account_borrow`). |
| program\_id | VARCHAR(16777216) | Program-owned market PDA (reserve / bank / vault), not the Solana program ID. |
| borrower\_address | VARCHAR(16777216) | Address of the account that borrowed funds from the lending protocol. |
| target\_address | VARCHAR(16777216) | Address of the target recipient of the borrowed tokens. |
| mint | VARCHAR(16777216) | Base58-encoded mint address of the SPL token being borrowed. |
| token\_name | VARCHAR(16777216) | Full name of the token being borrowed. |
| token\_symbol | VARCHAR(16777216) | Ticker symbol of the token being borrowed. |
| token\_decimals | NUMBER(38,0) | Number of decimal places used to represent the token's smallest unit. |
| raw\_amount\_str | VARCHAR(16777216) | Token amount in the smallest unit, as a string, to retain precision. |
| amount\_str | VARCHAR(16777216) | Normalized token amount, as a string, to retain precision. |
| amount | FLOAT | Token amount normalized by the token's decimal precision. |
| usd\_amount | FLOAT | USD value of the tokens borrowed at the time of the transaction. |
| usd\_exchange\_rate | FLOAT | USD price per unit of the token at the time of the event. |
| extra\_fields | VARIANT | JSON object containing additional fields from the onchain event that are not part of the standard schema. |
| txn\_id | VARCHAR(16777216) | Base58-encoded transaction signature on Solana. |
| txn\_index | NUMBER(38,0) | Zero-based position of this transaction within its slot. |
| signer | VARCHAR(16777216) | Primary signing account (fee payer) of the transaction. |
| instruction\_index | NUMBER(38,0) | Zero-based position of this instruction within the transaction's top-level instructions array. |
| inner\_instruction\_index | NUMBER(38,0) | Zero-based position of this inner instruction within its parent instruction's inner instructions array. -1 for top-level instructions. |
| pseudo\_instruction\_order | NUMBER(38,0) | Internal ordering key for instructions within a transaction that may lack an explicit index. |
| block\_slot | NUMBER(38,0) | Solana slot number in which this transaction was confirmed. |
| block\_height | NUMBER(38,0) | Number of confirmed blocks between this block and the genesis block (inclusive). |
| block\_timestamp | TIMESTAMP\_NTZ(9) | Timestamp (UTC) of the block in which this event was confirmed. |
| block\_hash | VARCHAR(16777216) | Cryptographic hash of the block header that contains this record. |
| unique\_id | VARCHAR(16777216) | Allium's deterministic unique identifier for this row. |
| \_created\_at | TIMESTAMP\_NTZ(9) | Timestamp (UTC) when this row was first written to the Allium platform. |
| \_updated\_at | TIMESTAMP\_NTZ(9) | Timestamp (UTC) of the most recent update to this row. |

***

### Sample Query

> [tab] Recent Loans
>
> Get recent loan events with essential details:
>
> ```sql theme={null}
> select
>   project,
>   protocol,
>   token_symbol,
>   amount,
>   usd_amount,
>   borrower_address,
>   block_timestamp
> from solana.lending.loans
> where block_timestamp >= current_timestamp - interval '7 days'
> order by block_timestamp desc
> limit 100
> ```

> [tab] Daily Loan Volume
>
> Calculate daily loan volume by protocol:
>
> ```sql theme={null}
> select
>   date(block_timestamp) as day,
>   project,
>   protocol,
>   count(*) as loan_count,
>   sum(usd_amount) as total_volume_usd
> from solana.lending.loans
> where block_timestamp >= current_timestamp - interval '30 days'
> group by day, project, protocol
> order by day desc, total_volume_usd desc
> ```
