Query editor
WITH token_constants AS (SELECT0x18084fbA666a33d37592fA2633fD49a74DD93a88 AS tbtc_address,0x1d50d75933b7b7c8ad94dbfb748b5756e3889c24 AS btc_from_address,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599 AS wbtc_address,1e18 AS tbtc_precision,1e8 AS wbtc_precision), all_deposits AS (SELECTDATE_TRUNC('day', evt_block_time) AS dt,"from",contract_address,CASEWHEN contract_address = tbtc_address AND "from" = btc_from_addressTHEN 'Native BTC'WHEN contract_address = tbtc_addressTHEN 'Native tBTC'WHEN contract_address = wbtc_addressTHEN 'wBTC'ELSE NULLEND AS asset_type,value / CASEWHEN contract_address = tbtc_addressTHEN tbtc_precisionWHEN contract_address = wbtc_addressTHEN wbtc_precisionEND AS amountFROM erc20_ethereum.evt_Transfer, token_constantsWHEREcontract_address IN (tbtc_address, wbtc_address)AND "to" = 0xAB13B8eecf5AA2460841d75da5d5D861fD5B8A39), daily_aggregates AS (SELECTdt,asset_type,COUNT(*) AS txs,COUNT(DISTINCT "from") AS unique_addresses,SUM(amount) AS amountFROM all_depositsGROUP BYdt,asset_type), cumulative_aggregates AS (SELECTdt,SUM(CASE WHEN asset_type = 'Native BTC' THEN amount ELSE 0 END) OVER (ORDER BY dt) AS cumulative_native_btc_amount,SUM(CASE WHEN asset_type = 'Native tBTC' THEN amount ELSE 0 END) OVER (ORDER BY dt) AS cumulative_native_tbtc_amount,SUM(CASE WHEN asset_type = 'wBTC' THEN amount ELSE 0 END) OVER (ORDER BY dt) AS cumulative_wbtc_amount,SUM(amount) OVER (ORDER BY dt) AS cumulative_btc_amount,SUM(CASE WHEN asset_type = 'Native BTC' THEN txs ELSE 0 END) OVER (ORDER BY dt) AS cumulative_native_btc_txs,SUM(unique_addresses) OVER (ORDER BY dt) AS cumulative_unique_addressesFROM daily_aggregates), adjusted_unique_addresses AS (SELECTdt,cumulative_unique_addresses + cumulative_native_btc_txs - (SELECTCOUNT(DISTINCT "from")FROM all_depositsWHERE