Query editor
WITH bridge_list AS (SELECT * FROM (VALUES(from_hex('0x3154Cf16ccdb4C6d922629664174b904d80F2C35'), 'Base'),(from_hex('0xd19d4B5d358258f05D7B411E21A1460D11B0876F'), 'Linea'),(from_hex('0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1'), 'Optimism'),(from_hex('0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6'), 'Scroll'),(from_hex('0x32400084c286cf3e17e7b677ea9583e60a000324'), 'zkSync'),(from_hex('0xae0Ee0A63A2cE6BaeEFFE56e7714FB4EFE48D419'), 'Starknet'),(from_hex('0xF65e73aAc9182e353600a916a6c7681F810f79C3'), 'Intmax'),(from_hex('0x0Ac498bCA32B00E2584171844fb9A5943398D9c1'), 'Intmax'),(from_hex('0x8315177ab297ba92a06054ce80a67ed4dbd7ed3a'), 'Arbitrum'),(from_hex('0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef'), 'Arbitrum'),(from_hex('0x5ef8efcb6f7bdf4a60e492b566be3a662c1c5460'), 'Blast'),(from_hex('0xb260fab183c501074e0e097075f0f081c9674b1e'), 'Blast'),(from_hex('0x6cA0D17f3b72fef5aF1f7838aA6A12668dECBb64'), 'Mantle'),(from_hex('0x56a46ae26f617f9e9f1a75505435B8b6C5E811e8'), 'Mantle')) AS t(bridge_address, protocol)),eth_prices AS (-- Get a single, reliable ETH price per daySELECT day, AVG(price) AS priceFROM prices.usd_dailyWHERE blockchain = 'ethereum'AND symbol = 'WETH'AND day >= DATE('2025-01-01')GROUP BY 1),token_prices AS (SELECT day, contract_address, AVG(price) AS priceFROM prices.usd_dailyWHERE blockchain = 'ethereum'AND day >= DATE('2025-01-01')GROUP BY 1,2),all_transactions AS (-- This CTE is the source of truth for protocol and gasSELECTDATE_TRUNC('day', t.block_time) AS day,t.block_time,t.hash,b.protocol, -- Protocol name is attached heret."from" AS user_address,t.value / 1e18 AS eth_deposited,(t.gas_used * t.gas_price) / 1e18 AS gas_fee_eth,t.successFROM ethereum.transactions tJOIN bridge_list b ON t."to" = b.bridge_address -- Join onceWHERE t.block_time >= TIMESTAMP '2025-01-01'AND t.success = TRUE),erc20_deposits AS (SELECTe.evt_block_time AS block_time,DATE_TRUNC('day', e.evt_block_time) AS day,e.evt_tx_hash AS hash,e."from" AS user_address,