Query editor
with timeframe as (selectcase when '{{LSD Timeframe}}' = 'monthly' then date('2020-11-20')when '{{LSD Timeframe}}' = 'weekly' then now() - interval '6' monthwhen '{{LSD Timeframe}}' = 'daily' then now() - interval '1' monthwhen '{{LSD Timeframe}}' = 'hourly' then now() - interval '7' dayend as start_date,case when '{{LSD Timeframe}}' = 'monthly' then 'month'when '{{LSD Timeframe}}' = 'weekly' then 'week'when '{{LSD Timeframe}}' = 'daily' then 'day'when '{{LSD Timeframe}}' = 'hourly' then 'hour'end as interval),lsd as (SELECT * FROM (VALUES0xae7ab96520de3a18e5e111b5eaab095312d7fe84,0xfe2e637202056d30016725477c5da089ab0a043a,0x5e8422345238f34275888049021821e8e08caa1f,0xae78736cd615f374d3085123a210448e74fc6393,0xe95a203b1a91a908f9b9ce46459d101078c2c3cb,0x20bc832ca081b91433ff6c17f85701b6e92486c5,0xbe9895146f7af43049ca1c1ae358b0541ea49704,0xa2e3356610840701bdf5611a53974510ae27e2e1,0xf951e335afb289353dc249e82926178eac7ded78) AS t (lsd)),mints as (select date_trunc('day',evt_block_time) as day, contract_address,sum(cast(value as double)) as mint, null as burnfrom erc20_ethereum.evt_Transferwhere "from" = 0x0000000000000000000000000000000000000000and contract_address in (select lsd from lsd)and evt_block_time >=date('2020-11-20')group by 1,2,4),burn as (select date_trunc('day',evt_block_time) as day, contract_address,null as mint,sum(cast(value as double) *-1) as burnfrom erc20_ethereum.evt_Transferwhere "to" in (0x0000000000000000000000000000000000000000,0xD15a672319Cf0352560eE76d9e89eAB0889046D3)and contract_address in (select lsd from lsd)and evt_block_time >=date('2020-11-20')group by 1,2,3),token as (select distinct contract_address, decimals, symbolfrom tokens.erc20where blockchain = 'ethereum'and contract_address in (select lsd from lsd)),summary as (select *from mintsunion allselect * from burn)select date_trunc((select interval from timeframe),a.day) as time,symbol,sum(mint/power(10,decimals)) as mint,sum(burn/power(10,decimals)) as burnfrom summary a