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

# Repayments

> Every loan repayment in a lending market.

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

`facts.lending_market_repayments` combines the repayment events of every lending protocol we decode into one table: one row per repayment of a loan. `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 repayment. Partition column.</td>
    </tr>

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

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

    <tr>
      <td><code>log\_index</code></td>
      <td><code>INT64</code></td>
      <td>Position of the repayment 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 repayment happened on.</td>
    </tr>

    <tr>
      <td><code>lending\_market\_id</code></td>
      <td><code>STRING</code></td>
      <td>Market the repayment entered; 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 repaid: <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 repaid.</td>
    </tr>

    <tr>
      <td><code>borrower\_address</code></td>
      <td><code>STRING</code></td>
      <td>Account whose debt was repaid.</td>
    </tr>

    <tr>
      <td><code>repayer\_address</code></td>
      <td><code>STRING</code></td>
      <td>Account that paid, when repaid for another account.</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>
  </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 market, one day">
    **Read one market's repayments 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
        repayments.block_timestamp,
        repayments.transaction_hash,
        repayments.borrower_address,
        cast(repayments.amount_raw as bignumeric) / pow(10, tokens.decimals) as amount
    from `facts.lending_market_repayments` as repayments
    join `dimensions.lending_markets` as markets
        using (lending_market_id)
    join `dimensions.tokens` as tokens
        using (token_id)
    where markets.project_id = 'compound'
      and markets.underlying_symbol = 'WETH'
      and markets.chain_id = 'ethereum'
      and repayments.block_timestamp >= timestamp('2026-08-01')
      and repayments.block_timestamp < timestamp('2026-08-02')
    limit 100
    ```
  </Tab>

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

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