Skip to content

Releases: pinax-network/substreams-evm-tokens

native-balances-v0.2.0

26 Aug 13:00
be7ea01
Compare
Choose a tag to compare

What's Changed

Test with Avalanche network (no extended blocks)

  • Now supports eth_get_balance to fetch Native balances for extended & no-extended blocks
  • supports chunk_size as spkg params

Implements eth_get_balance:

requests.requests.push(RpcGetBalanceRequest {
    address: account.to_vec(),
    block: format!("{:#x}", block), // to hex
});

Full Changelog: clickhouse-uniswaps-v0.2.0...native-balances-v0.2.0

clickhouse-uniswaps-v0.2.0

18 Jul 03:11
Compare
Choose a tag to compare

What's Changed

✅ new features/fields

  • Swaps add token & decimals
    • add input_token & output_tokens
    • add input_decimals & output_decimals
  • Replace price field as MV input_amount / output_amount
  • Define pool_activity_summary TABLE as SummingMergeTree
    • sums transactions by Pool
  • Update REFRESH EVERY 1 MINUTE for ohlc_prices table (should drastically speed up ingestion time)

❌ Breaking changes

  • Swaps amount0/amount1 changes
    • rename swaps.amount0 => swaps.input_amount
    • rename swaps.amount1 => swaps.output_amount
  • Remove swaps.recipient field (was Null for Uniswap V4), no longer a concept in Swaps due to Aggregators doing most of the trading.
  • Change Volume to Int256 instead of Float64
    • gross_volume0 & gross_volume1 to Int256
    • net_volume0 & net_volume1 to Int256
  • remove name & symbol from OHLC (names & symbol change over time, best to fetch these at query time)
  • remove decimals scale handling in gross_volume & prices (must be computed at Query time)

⚠️ Refactored/clean ups

  • Remove extra INDEX from tables that are not being used in Token API
    • kept only idx_tx_hash TYPE bloom_filter GRANULARITY 1
  • Convert ReplacingMergeTree to MergeTree for those that do not use Replacing functionality
  • add global_sequence_reverse to uniswap_v3_pool_created & uniswap_v2_pair_created
    • change to ENGINE = ReplacingMergeTree(global_sequence_reverse)

Data sample for swaps

block_num:       22940200 -- 22.94 million
block_hash:      0x37e205b2fb2fc775a711a2115a664df3479c0b58c29e9ea7b2523b0c6c7ca588
timestamp:       2025-07-17 16:44:47
tx_hash:         0xd7401dfb989c81aa43ee16c01442a2ffae8cfff93cc6aade8504f68926b17e44
tx_from:         0x710d9b5c4fa0cf4c1603790e332c12188161c8b0
tx_to:           0x710d9b5c4fa0cf4c1603790e332c12188161c8b0
ordinal:         2759
caller:          0x66a9893cc07d91d95644aedd05d03f95e1dba8af
pool:            0x72331fcb696b0151904c03584b66dc8365bc63f8a144d89a773384e3a579ca73
sender:          0x66a9893cc07d91d95644aedd05d03f95e1dba8af
factory:         0x000000000004444c5dc75cb358380d2e3de08a90
input_amount:    180000000000000000
input_token:     0x0000000000000000000000000000000000000000
input_decimals:  18
output_amount:   610885871 -- 610.89 million
output_token:    0xdac17f958d2ee523a2206206994597c13d831ec7
output_decimals: 6
protocol:        uniswap_v4

SQL Examples

OHLC for WETH/USDT

-- OHLC Prices by Pool --
WITH (
      pow(10, decimals0) AS scale0,
      pow(10, decimals1) AS scale1,
      pow(10, decimals0 - decimals1) AS scale,
      2 AS precision -- user defined
) SELECT
      timestamp,
      'WETH/USDT' AS ticker,

      -- OHLC --
      floor(argMinMerge(open0) * scale, precision)                        AS open,
      floor(quantileDeterministicMerge(0.99)(quantile0) * scale, precision)   AS high,
      floor(quantileDeterministicMerge(0.01)(quantile0) * scale, precision)    AS low,
      floor(argMaxMerge(close0) * scale, precision)                       AS close,

      -- volume --
      floor(sum(gross_volume0) / scale0, precision)         AS "gross volume (ETH)",
      floor(sum(gross_volume1) / scale1, precision)         AS "gross volume (USD)",
      floor(sum(net_flow0) / scale0, precision)             AS "net flow (ETH)",
      floor(sum(net_flow1) / scale1, precision)             AS "net flow (USD)",

      -- universal --
      uniqMerge(uaw)          AS uaw,
      sum(transactions)       AS transactions
FROM ohlc_prices
WHERE pool = lower('0x72331fcb696b0151904c03584b66dc8365bc63f8a144d89a773384e3a579ca73') -- Uniswap V4 WETH/USDT
GROUP BY pool, timestamp, decimals0, decimals1
ORDER BY timestamp DESC
LIMIT 10;

    ┌───────────timestamp─┬─ticker────┬────open─┬────high─┬─────low─┬───close─┬─gross volume (ETH)─┬─gross volume (USD)─┬─net flow (ETH)─┬─net flow (USD)─┬─uaw─┬─transactions─┐
 1. │ 2025-07-18 02:00:00 │ WETH/USDT │ 3600.643625.393589.553600.6414433.0852045358.12924.26-3307896.4212716292. │ 2025-07-18 01:00:00 │ WETH/USDT │  3563.63618.313531.763563.635552.46127502677.5-4164.9514961626.0118126373. │ 2025-07-18 00:00:00 │ WETH/USDT │ 3512.173539.283463.273512.1712772.7744672527.91-3268.8211483158.1211216114. │ 2025-07-17 23:00:00 │ WETH/USDT │  3507.73518.123466.233507.718207.7863614495.83-589.032075611.313318185. │ 2025-07-17 22:00:00 │ WETH/USDT │ 3478.373491.43455.543478.3710969.8738123439.82122.29-403755.319012786. │ 2025-07-17 21:00:00 │ WETH/USDT │ 3494.543498.733419.213494.5420946.8572624773.36-2790.919644798.8513619537. │ 2025-07-17 20:00:00 │ WETH/USDT │ 3399.233416.223376.613399.2315771.0353590941.46-516.431789684.8511315578. │ 2025-07-17 19:00:00 │ WETH/USDT │  3443.63451.413408.283443.67297.0925053358.881036.75-3532523.34799819. │ 2025-07-17 18:00:00 │ WETH/USDT │ 3432.333440.733417.443432.336817.1523370140.82-227.76792040.1291111510. │ 2025-07-17 17:00:00 │ WETH/USDT │ 3400.533424.83390.553400.538113.1327627427.65-2174.467426578.68831110 │
    └─────────────────────┴───────────┴─────────┴─────────┴─────────┴─────────┴────────────────────┴────────────────────┴────────────────┴────────────────┴─────┴──────────────┘

Full Changelog: clickhouse-tokens-v1.16.0...clickhouse-uniswaps-v0.2.0

Search top pools by total transactions

SELECT
    pool,
    token0,
    token1,
    transactions
FROM pool_activity_summary
WHERE token0 != ''
ORDER BY transactions DESC
LIMIT 10

Query id: 3bc4e3b5-8fdd-4929-8042-f1fffbaf67aa

    ┌─pool───────────────────────────────────────────────────────────────┬─token0─────────────────────────────────────┬─token1─────────────────────────────────────┬─transactions─┐
 1. │ 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640                         │ 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │       1122942. │ 0x72331fcb696b0151904c03584b66dc8365bc63f8a144d89a773384e3a579ca73 │ 0x0000000000000000000000000000000000000000 │ 0xdac17f958d2ee523a2206206994597c13d831ec7 │        787003. │ 0x4d63da0421ab1d71fbf2a3d3c8625a66d9b9799d                         │ 0xdac17f958d2ee523a2206206994597c13d831ec7 │ 0xe2ad0bf751834f2fbdc62a41014f84d67ca1de2a │        622284. │ 0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852                         │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │ 0xdac17f958d2ee523a2206206994597c13d831ec7 │        430785. │ 0xb570b29573fe661ccf607ba47d91b737148d8289                         │ 0x06168a340096872bbf5061e5ebad84a7f172bb00 │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │        353266. │ 0x9eed63e14f2cceb1434546005b4445049b41a6ac                         │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │ 0xc7eae11e9e03500461a0b9169addac8ae2f0e37d │        303247. │ 0x25bda6e622a477ca702902fab161ace70839994b                         │ 0x698acb976e0c07078b06cdc5093f7cdaf55d94d6 │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │        294468. │ 0x10c4e72abd373295e613e3d2c2c5067d33a0e4a8                         │ 0x6055dc6ff1077eebe5e6d2ba1a1f53d7ef8430de │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │        269219. │ 0xcc7fa2fa60b745938197b834001780efb89e03a4                         │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │ 0xfed9d09e347af985a055a4f5cd2d8a30a7d692cc │        2499510. │ 0x2e3b8bcb8da0b96a5f845705fa7510f4d5f63f28                         │ 0x22fb1d972e2d37f5e8ff6ff3655aa225e3485de1 │ 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 │        24683 │
    └────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────┴────────────────────────────────────────────┴──────────────┘

Search Swaps by Pool

WITH (
    pow(10, input_decimals) AS scale0,
    pow(10, output_decimals) AS scale1,
    pow(10, input_decimals - output_decimals) AS scale
)
SELECT
    input_token as input_token,
    input_amount / scale0 AS input_amount,
    input_decimals,
    output_token as output_token,
    output_decimals,
    output_amount / scale1 AS output_amount,
    price * scale AS price
FROM swaps
WHERE pool = '0x72331fcb696b0151904c03584b66dc8365bc63f8a144d89a773384e3a579ca73'
LIMIT 20;
    ┌─input_token────────────────────────────────┬────────input_amount─┬─input_decimals─┬─output_token───────────────────────────────┬─output_decimals─┬─output_amount─┬──────────────price─┐
 1. │ 0x0000000000000000000000000000000000000000 │            0.46360518 │ 0xdac17f958d2ee523a2206206994597c13d831ec7 │               61669.2302283600.5440579803932. │ 0x0000000000000000000000000000000000000000 │             0.0157518 │ 0xdac17f958d2ee523a2206206994597c13d831ec7 │               656.7226343601.43707936507963. │ 0x0000000000000000000000000000000000000000 │   4.342606455440937 │            ...
Read more

erc20-transfers-v0.2.1

26 Jun 02:17
Compare
Choose a tag to compare
  • Add log_index field
  • Update erc20-stores which depends on erc20-transfers spkg

erc20-metadata-v0.2.1

26 Jun 19:16
Compare
Choose a tag to compare

What's Changed

Full Changelog: clickhouse-nfts-v0.6.2...erc20-metadata-v0.1.2

clickhouse-tokens-v1.16.0

26 Jun 19:18
Compare
Choose a tag to compare

Updates

  • add log_index to transfers & erc20_transfers
  • fix SQL: Incorrect amount in transfers table #92
  • Remove duplicate eth_call by @YaroShkvorets in #103
  • Remove erc20_metadata_functions module (events have been incorporated in erc20_metadata)
  • Update erc20_stores with latest erc20-transfers package (will require re-processing stores)

New *.spkg versions

Full Changelog: erc20-transfers-v0.2.1...clickhouse-tokens-v1.15.1

clickhouse-nfts-v0.6.2

13 Jun 17:48
Compare
Choose a tag to compare
  • Changes: 7dfb341
  • Bumped from v0.6.1

clickhouse-nfts-v0.6.1

12 Jun 18:51
ae6fb79
Compare
Choose a tag to compare

Changes

  • Alter punk_index to use UInt256 instead of UInt64

Alter SQL table

No change in Substreams, only SQL table structure

ALTER TABLE punk_assigns MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_transfers MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_bought MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_bid_entered MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_bid_withdrawn MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_no_longer_for_sale MODIFY COLUMN punk_index UInt256;
ALTER TABLE punk_offered MODIFY COLUMN punk_index UInt256;

What's Changed

Full Changelog: clickhouse-nfts-v0.6.0...clickhouse-nfts-v0.6.1

clickhouse-nfts-v0.6.0

06 Jun 01:57
8db6ddc
Compare
Choose a tag to compare

What's Changed

ERC721 new data

CryptoPunks events have also been included in ERC721 tables & metadata

New CryptoPunks TABLES

  • punk_assigns
  • punk_transfers
  • punk_bought
  • punk_bid_entered
  • punk_bid_withdrawn
  • punk_no_longer_for_sale
  • punk_offered

Notes 📔

  • CryptoPunks include their own marketplace for NFT sales, however this release does not include these sales in OHLC.
  • For NFT sales, reference punk_bought / punk_bid_entered TABLES
  • Some punk_bought events contain Null value, refer to value_is_null field
  • punk_assigns is equivalent as a Mint event

Full Changelog: clickhouse-tokens-v1.15.0...clickhouse-nfts-v0.6.0

tokens-v0.2.0

23 May 21:05
76c28fd
Compare
Choose a tag to compare

Fixes #84

WETH (version 9) only includes Deposit & Withdraw events, does not include a Transfer event

This can cause the user to:

  • Redeem WETH via withdraw
  • ✅ Update Native Balances
  • ❌ NOT update ERC-20 balance (remains the same)

Substreams Packages updated

  • erc20-transfers
  • erc20-supply (depends on erc20-transfers)
  • erc20-balances-rpc (depends on erc20-transfers)

clickhouse-tokens-v1.15.0

23 May 21:22
76c28fd
Compare
Choose a tag to compare