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

# solana_utils.daily_balances

> Historical daily SOL and SPL token balances for every address on Solana.

export const TableSample = ({tableName, tableSchema}) => <>
    <div className="hidden dark:block">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}&darkMode=true`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
    <div className="dark:hidden">
      <iframe src={`https://dune.com/embeds/3419983/5785629?table_schema_t6f0df=${tableSchema}&table_name_t6f0df=${tableName}`} style={{
  width: '100%',
  height: '500px',
  border: 'none',
  marginTop: '10px'
}} />
    </div>
  </>;

The `solana_utils.daily_balances` table provides end-of-day balance snapshots for every address on Solana, covering both native SOL and SPL token holdings. This table is the historical counterpart to `solana_utils.latest_balances`.

Each row represents the balance for a specific address, token, and day. The table is partitioned by `month` for query performance and is sourced from `solana.account_activity`.

### When to Use This Table

* Track historical balance changes for a wallet over time
* Analyze token holder distribution trends
* Build time-series portfolio valuation charts
* Monitor treasury balances for Solana DAOs and protocols

### Query Performance

**Partition key:** `month`

Always include a time filter (`day` range) and filter on `address` or `token_mint_address` for best performance.

```sql theme={null}
-- ✅ Good: specific address + time range
SELECT *
FROM solana_utils.daily_balances
WHERE address = 'FG4Y3yX4AAchp1HvNZ7LfzFTewF2f6nDoMDCohTFrdpk'
  AND day >= DATE '2025-01-01'

-- ❌ Slow: no time or address filter
SELECT * FROM solana_utils.daily_balances
WHERE token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
```

## Table Schema

| Column                | Type             | Description                                |
| --------------------- | ---------------- | ------------------------------------------ |
| `day`                 | `TIMESTAMP`      | Day of the balance snapshot                |
| `month`               | `DATE`           | Month partition key                        |
| `address`             | `VARCHAR`        | Solana wallet address                      |
| `sol_balance`         | `DOUBLE`         | Native SOL balance at end of day           |
| `token_mint_address`  | `VARCHAR`        | Mint address of the SPL token              |
| `token_balance`       | `DECIMAL(38,18)` | SPL token balance in display units         |
| `token_balance_owner` | `VARCHAR`        | Owner of the token balance                 |
| `block_time`          | `TIMESTAMP`      | Block time of the last balance change      |
| `block_slot`          | `BIGINT`         | Block slot of the last balance change      |
| `unique_address_key`  | `VARCHAR`        | Unique key for address + token combination |
| `updated_at`          | `TIMESTAMP`      | When this record was last updated          |

## Table Sample

<TableSample tableSchema="solana_utils" tableName="daily_balances" />

## Example Queries

**Daily SOL balance for a wallet over the last 30 days:**

```sql theme={null}
SELECT
  day,
  sol_balance,
  token_balance,
  token_mint_address
FROM solana_utils.daily_balances
WHERE address = 'FG4Y3yX4AAchp1HvNZ7LfzFTewF2f6nDoMDCohTFrdpk'
  AND day >= NOW() - INTERVAL '30' DAY
ORDER BY day DESC
```

**Track USDC balance history for an address:**

```sql theme={null}
SELECT
  day,
  token_balance
FROM solana_utils.daily_balances
WHERE address = 'FG4Y3yX4AAchp1HvNZ7LfzFTewF2f6nDoMDCohTFrdpk'
  AND token_mint_address = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' -- USDC
  AND day >= DATE '2025-01-01'
ORDER BY day
```
