Query editor
with wrapped_btcs as (selectcontract_address,symbol,_decimalfrom(VALUES(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599, 'WBTC', 8),(0x0316EB71485b0Ab14103307bf65a021042c6d380, 'HBTC', 18),(0xeb4c2781e4eba804ce9a9803c67d0893436bb27d, 'renBTC', 8),(0xfe18be6b3bd88a2d2a7f928d00292e7a9963cfc6, 'sBTC', 18),(0x18084fba666a33d37592fa2633fd49a74dd93a88, 'tBTC', 18),(0x3212b29E33587A00FB1C83346f5dBFA69A458923, 'imBTC', 8),(0x0327112423f3a68efdf1fcf402f6c5cb9f7c33fd, 'BTC++', 18)) as t(contract_address, symbol, _decimal)),times AS (select*FROM (select distinct date_trunc('{{period}}', time) as dt from bitcoin.blocks)CROSS JOIN (select distinct symbol from wrapped_btcs)),btc_on_ethereum_supply as (selectdate_trunc('{{period}}', evt_block_time) as dt,contract_address,value as amountfrom erc20_ethereum.evt_Transferwhere "from" = 0x0000000000000000000000000000000000000000 andcontract_address in (select distinct contract_address from wrapped_btcs)UNION ALLselectdate_trunc('{{period}}', evt_block_time) as dt,contract_address,-value as amountfrom erc20_ethereum.evt_Transferwhere to = 0x0000000000000000000000000000000000000000and contract_address in (select distinct contract_address from wrapped_btcs)),btc_on_ethereum_supply_sum as (selectdt,symbol,sum(amount/pow(10, _decimal)) as amountfrom btc_on_ethereum_supply as bleft join wrapped_btcs as wb on b.contract_address = wb.contract_addressgroup by 1, 2),total as (select t.dt, t.symbol, COALESCE(sup.amount, 0) as amountfrom times as tleft join btc_on_ethereum_supply_sum as sup on t.dt = sup.dt and t.symbol = sup.symbol)select*,sum(amount) over(partition by symbol order by dt asc) as total_amountfrom totalorder by total_amount desc