prices.latest

Overview

The prices.latest table provides the most recently available price for each token across all supported blockchains. This table is ideal for calculating current token values or displaying up-to-date prices.

Table Schema

ColumnTypeDescription
blockchainvarcharBlockchain identifier (e.g., ‘ethereum’, ‘arbitrum’)
contract_addressvarbinaryToken contract address (fixed address for native tokens)
symbolvarcharToken symbol (e.g., ‘ETH’, ‘USDC’)
pricedoubleMost recent token price in USD
decimalsintToken decimals
timestamptimestampTimestamp when this price was recorded
volumedoubleTrading volume in USD (from price source)
sourcevarcharData source (‘coinpaprika’ or ‘dex.trades’)
source_timestamptimestampExact timestamp of the source data point

Implementation Details

The latest prices are built by:

  1. Taking the most recent price observation from each data source
  2. Selecting the latest observation per token across all sources
  3. Refreshed hourly to ensure prices stay current

Usage

This table is perfect for querying the current price of tokens without needing to filter by timestamp or perform additional aggregations. It’s designed for efficiency when you just need the most recent price.

Usage Examples

Here are some examples of how to use the prices tables.

Get current prices for major tokens:

SELECT
  blockchain,
  symbol, -- Symbol included for readable output only
  price,
  timestamp
FROM prices.latest
WHERE (blockchain, contract_address) IN (
  ('ethereum', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), -- WETH
  ('ethereum', 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48), -- USDC
  ('ethereum', 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599), -- WBTC
  ('arbitrum', 0x82af49447d8a07e3bd95bd0d56f35241523fbab1), -- WETH on Arbitrum
  ('optimism', 0x4200000000000000000000000000000000000006)  -- WETH on Optimism
)

Calculate total USD value of token holdings:

WITH token_balances AS (
  SELECT
    token_address,
    sum(amount) as total_tokens
  FROM my_token_balance_table
  GROUP BY 1
)

SELECT
  b.token_address,
  p.symbol, -- Symbol included for readable output only
  b.total_tokens,
  b.total_tokens * p.price as usd_value
FROM token_balances b
JOIN prices.latest p
  ON p.blockchain = 'ethereum'
  AND p.contract_address = b.token_address

Get prices for native tokens across multiple blockchains:

-- Join with dune.blockchains to get native token prices
SELECT
  b.name as blockchain,
  b.token_symbol as native_token_symbol,
  p.price as native_token_price,
  p.timestamp
FROM dune.blockchains b
JOIN prices.latest p
  ON p.blockchain = b.name
  AND p.contract_address = b.token_address
WHERE b.name IN ('ethereum', 'arbitrum', 'optimism', 'polygon','gnosis','solana')

Data Quality Notes

  • Native tokens (like ETH, BNB) are assigned fixed addresses for consistency
  • For native tokens, use dune.blockchains table to get the standardized address for each blockchain
  • The timestamp column shows when the price was last updated, useful for determining freshness
  • For historical analysis, use prices.day, prices.hour, or prices.minute instead
  • Always use contract_address and blockchain for precise token identification, never use symbol for joins or filters