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

# Flash loans

> Every flash loan: borrowed and repaid inside one transaction.

<Info>
  **In progress.** This table is not served yet. The page documents it as it lands.
</Info>

`facts.lending_market_flash_loans` combines the flash-loan events of every lending protocol we decode into one table: one row per flash loan. A flash loan borrows tokens and repays them with a fee inside one transaction. `lending_market_id` keys each row to its market in the [Registry](/docs/catalog/lending/registry).

## Columns

<table>
  <thead>
    <tr>
      <th width="280">Column</th>
      <th width="130">Type</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>block\_timestamp</code></td>
      <td><code>TIMESTAMP</code></td>
      <td>Time of the block containing the flash loan. Partition column.</td>
    </tr>

    <tr>
      <td><code>block\_number</code></td>
      <td><code>INT64</code></td>
      <td>Number of the block containing the flash loan.</td>
    </tr>

    <tr>
      <td><code>transaction\_hash</code></td>
      <td><code>STRING</code></td>
      <td>Hash of the transaction that emitted the flash-loan event.</td>
    </tr>

    <tr>
      <td><code>log\_index</code></td>
      <td><code>INT64</code></td>
      <td>Position of the flash-loan event in the block.</td>
    </tr>

    <tr>
      <td><code>unique\_id</code></td>
      <td><code>INT64</code></td>
      <td>Row key: fingerprint of <code>chain\_id</code>, <code>block\_number</code>, <code>transaction\_hash</code>, <code>log\_index</code>.</td>
    </tr>

    <tr>
      <td><code>chain\_id</code></td>
      <td><code>STRING</code></td>
      <td>Chain the flash loan happened on.</td>
    </tr>

    <tr>
      <td><code>lending\_market\_id</code></td>
      <td><code>STRING</code></td>
      <td>Market the loan drew from; joins <code>dimensions.lending\_markets</code>.</td>
    </tr>

    <tr>
      <td><code>project\_id</code></td>
      <td><code>STRING</code></td>
      <td>Protocol operating the market, such as <code>aave</code>.</td>
    </tr>

    <tr>
      <td><code>token\_id</code></td>
      <td><code>STRING</code></td>
      <td>Token borrowed: <code>\{token\_address}-\{chain\_id}</code>.</td>
    </tr>

    <tr>
      <td><code>token\_address</code></td>
      <td><code>STRING</code></td>
      <td>Contract address of the token borrowed.</td>
    </tr>

    <tr>
      <td><code>initiator\_address</code></td>
      <td><code>STRING</code></td>
      <td>Account that started the flash loan.</td>
    </tr>

    <tr>
      <td><code>target\_address</code></td>
      <td><code>STRING</code></td>
      <td>Contract that received the loan.</td>
    </tr>

    <tr>
      <td><code>amount\_raw</code></td>
      <td><code>STRING</code></td>
      <td>Raw amount as text; a <code>uint256</code> exceeds every BigQuery number type.</td>
    </tr>

    <tr>
      <td><code>premium\_raw</code></td>
      <td><code>STRING</code></td>
      <td>Fee paid for the loan as text, in the borrowed token; null where the protocol charges none.</td>
    </tr>
  </tbody>
</table>

## Sample queries

<Warning>
  The table is partitioned on `block_timestamp`. Bound that column in every query; without a bound the query reads the whole table.
</Warning>

<Tabs>
  <Tab title="One token, one day">
    **Read one token's flash loans on a single day.** Cast `amount_raw` to `BIGNUMERIC` and divide by `10^decimals` from `dimensions.tokens` to get the token amount.

    ```sql theme={null}
    select
        flash_loans.block_timestamp,
        flash_loans.transaction_hash,
        flash_loans.initiator_address,
        cast(flash_loans.amount_raw as bignumeric) / pow(10, tokens.decimals) as amount
    from `facts.lending_market_flash_loans` as flash_loans
    join `dimensions.tokens` as tokens
        using (token_id)
    where flash_loans.token_id = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2-ethereum'
      and flash_loans.block_timestamp >= timestamp('2026-08-01')
      and flash_loans.block_timestamp < timestamp('2026-08-02')
    limit 100
    ```
  </Tab>

  <Tab title="Daily USD volume">
    **Sum daily flash-loan volume in USD per protocol.** The table carries token amounts; USD comes from [Prices](/docs/catalog/tokens/prices).

    ```sql theme={null}
    select
        timestamp_trunc(flash_loans.block_timestamp, day) as day,
        flash_loans.project_id,
        round(sum(cast(flash_loans.amount_raw as bignumeric) / pow(10, tokens.decimals) * prices.price)) as borrowed_usd
    from `facts.lending_market_flash_loans` as flash_loans
    join `dimensions.tokens` as tokens
        using (token_id)
    join `metrics.tokens_prices_daily` as prices
        on prices.token_id = flash_loans.token_id
        and prices.timestamp = timestamp_trunc(flash_loans.block_timestamp, day)
    where flash_loans.block_timestamp >= timestamp('2026-08-01')
      and flash_loans.block_timestamp < timestamp('2026-08-08')
    group by day, flash_loans.project_id
    order by day, borrowed_usd desc
    ```
  </Tab>
</Tabs>
