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

# Balances at Any Timestamp

> Token balances for any list of addresses at a specific point in time, from the daily snapshot plus the credits and debits since.

The `sql_table_<chain>_get_balances_at_timestamp` function calculates precise token balances for any list of addresses at a specific point in time. It combines the daily balance snapshot with intraday transaction changes using a **Base + Delta** approach:

**Final Balance = EOD Snapshot + Sum(Credits - Debits since snapshot)**

This is useful when daily snapshots are not granular enough and you need balances at a specific hour or minute.

## Function Details

| Property | Value |
| - | - |
| Function Name | `<chain>.udfs.sql_table_<chain>_get_balances_at_timestamp` |
| Function Status | Production-Ready |

## Chain Coverage

| Table | Chains |
| - | - |
| `<chain>.udfs.sql_table_<chain>_get_balances_at_timestamp` | <details><summary>30 chains</summary>[Aptos](https://docs.allium.so/historical-data/supported-blockchains/move-ecosystem/aptos/assets/fungible-balances-daily.md), [Sui](https://docs.allium.so/historical-data/supported-blockchains/move-ecosystem/sui/assets/fungible-balances-daily.md), [ApeChain](https://docs.allium.so/historical-data/supported-blockchains/evm/apechain/assets/fungible-balances-daily.md), [Arbitrum](https://docs.allium.so/historical-data/supported-blockchains/evm/arbitrum/assets/fungible-balances-daily.md), [Arc](https://docs.allium.so/historical-data/supported-blockchains/evm/arc/assets/fungible-balances-daily.md), [Avalanche](https://docs.allium.so/historical-data/supported-blockchains/evm/avalanche/assets/fungible-balances-daily.md), [B3 ◽](https://docs.allium.so/historical-data/supported-blockchains/evm/b3/assets/fungible-balances-daily.md), [Base](https://docs.allium.so/historical-data/supported-blockchains/evm/base/assets/fungible-balances-daily.md), [Berachain](https://docs.allium.so/historical-data/supported-blockchains/evm/berachain/assets/fungible-balances-daily.md), [Blast ◽](https://docs.allium.so/historical-data/supported-blockchains/evm/blast/assets/fungible-balances-daily.md), [BNB Smart Chain](https://docs.allium.so/historical-data/supported-blockchains/evm/bsc/assets/fungible-balances-daily.md), [Celo](https://docs.allium.so/historical-data/supported-blockchains/evm/celo/assets/fungible-balances-daily.md), [Core](https://docs.allium.so/historical-data/supported-blockchains/evm/core/assets/fungible-balances-daily.md), [Ethereum](https://docs.allium.so/historical-data/supported-blockchains/evm/ethereum/assets/fungible-balances-daily.md), [HyperEVM](https://docs.allium.so/historical-data/supported-blockchains/evm/hyperevm/assets/fungible-balances-daily.md), [Ink](https://docs.allium.so/historical-data/supported-blockchains/evm/ink/assets/fungible-balances-daily.md), [Linea](https://docs.allium.so/historical-data/supported-blockchains/evm/linea/assets/fungible-balances-daily.md), [MegaETH 🌱](https://docs.allium.so/historical-data/supported-blockchains/evm/megaeth/assets/fungible-balances-daily.md), [Monad](https://docs.allium.so/historical-data/supported-blockchains/evm/monad/assets/fungible-balances-daily.md), [Optimism](https://docs.allium.so/historical-data/supported-blockchains/evm/optimism/assets/fungible-balances-daily.md), [Plasma](https://docs.allium.so/historical-data/supported-blockchains/evm/plasma/assets/fungible-balances-daily.md), [Polygon](https://docs.allium.so/historical-data/supported-blockchains/evm/polygon/assets/fungible-balances-daily.md), [Scroll](https://docs.allium.so/historical-data/supported-blockchains/evm/scroll/assets/fungible-balances-daily.md), [Soneium](https://docs.allium.so/historical-data/supported-blockchains/evm/soneium/assets/fungible-balances-daily.md), [Sonic](https://docs.allium.so/historical-data/supported-blockchains/evm/sonic/assets/fungible-balances-daily.md), [Stable](https://docs.allium.so/historical-data/supported-blockchains/evm/stable/assets/fungible-balances-daily.md), [Tempo](https://docs.allium.so/historical-data/supported-blockchains/evm/tempo/assets/fungible-balances-daily.md), [Unichain](https://docs.allium.so/historical-data/supported-blockchains/evm/unichain/assets/fungible-balances-daily.md), [Vana](https://docs.allium.so/historical-data/supported-blockchains/evm/vana/assets/fungible-balances-daily.md), [World Chain](https://docs.allium.so/historical-data/supported-blockchains/evm/worldchain/assets/fungible-balances-daily.md)</details> |

## Usage

```sql theme={null}
SELECT * FROM TABLE(<chain>.UDFS.SQL_TABLE_<CHAIN>_GET_BALANCES_AT_TIMESTAMP(
    ARRAY_CONSTRUCT('0xAddress1', '0xAddress2'),
    '2025-06-15 14:30:00'::TIMESTAMP_NTZ
));
```

> [!NOTE]
>
> For EVM chains, input addresses are automatically lowercased. For non-EVM chains (SUI, Aptos), addresses are used as-is.

## Example: Portfolio balance at a specific time

```sql theme={null}
SELECT
  address,
  token_symbol,
  balance,
  usd_balance,
  calculation_method
FROM TABLE(ETHEREUM.UDFS.SQL_TABLE_ETHEREUM_GET_BALANCES_AT_TIMESTAMP(
    ARRAY_CONSTRUCT('0xe649a394fb16b58ee2e59feb2ea571e7733c812a'),
    '2025-06-15 14:30:00'::TIMESTAMP_NTZ
))
WHERE balance > 0
ORDER BY usd_balance DESC NULLS LAST;
```

## Return Columns

| Column | Type | Description |
| - | - | - |
| `address` | VARCHAR | Wallet address |
| `token_address` | VARCHAR | Token contract address |
| `token_name` | VARCHAR | Token name |
| `token_symbol` | VARCHAR | Token symbol |
| `token_decimals` | NUMBER | Token decimal places |
| `raw_balance_str` | VARCHAR | Raw balance as string (precision-safe) |
| `raw_balance` | FLOAT | Raw balance as float |
| `balance_str` | VARCHAR | Decimal-adjusted balance as string |
| `balance` | FLOAT | Decimal-adjusted balance |
| `usd_exchange_rate` | FLOAT | USD price at snapshot time |
| `usd_balance` | FLOAT | Balance in USD |
| `last_activity_block_timestamp` | TIMESTAMP\_NTZ | Timestamp of last activity |
| `last_activity_block_number` | NUMBER | Block number of last activity |
| `base_date` | DATE | Date of the EOD snapshot used |
| `intraday_adjustments_applied` | BOOLEAN | Whether intraday deltas were applied |
| `calculation_method` | VARCHAR | `eod_only` or `eod_with_intraday_adjustment` |
