Query editor
with wormhole_tokens as (select date_trunc('day', evt_block_time) as txn_date, contract_address, sum(case when "from" = 0x8d2de8d2f73f1f4cab472ac9a881c9b123c79627 then cast("value" as double) else 0 end) * -1 as deposited_asset, sum(case when "to" = 0x8d2de8d2f73f1f4cab472ac9a881c9b123c79627 then cast("value" as double) else 0 end) as withdrawn_assetfrom erc20_base.evt_transferwhere ("from" = 0x8d2de8d2f73f1f4cab472ac9a881c9b123c79627or "to" = 0x8d2de8d2f73f1f4cab472ac9a881c9b123c79627)and evt_block_time < current_dateand evt_block_number >= 1422314group by 1, 2), wormhole_net as (select a.txn_date, a.contract_address, sum(a.net_amount) over (partition by a.contract_address order by a.txn_date asc) as tkn_amountfrom (select txn_date, contract_address, (deposited_asset + withdrawn_asset) as net_amountfrom wormhole_tokens) a), daily as (select txn_date, contract_address, sum(tkn_amount) as asset_tvsfrom wormhole_netgroup by txn_date, contract_address), date_parameter as (select casewhen '{{timeframe}}' = 'show all time' then cast('2023-07-17' as date)when '{{timeframe}}' = 'past one year' then now() - interval '1' yearwhen '{{timeframe}}' = 'past six months' then now() - interval '6' monthwhen '{{timeframe}}' = 'past three months' then now() - interval '3' monthwhen '{{timeframe}}' = 'past one month' then now() - interval '1' monthend as start_date), mkt_prices as (select date_trunc('day', "minute") as mkt_date, contract_address, symbol, decimals, avg(price) as agv_pricefrom prices.usdwhere blockchain = 'base'group by 1, 2, 3, 4), per_asset_usd as (select d.txn_date, mkt.symbol, d.asset_tvs / pow(10, mkt.decimals) * mkt.agv_price as asset_tvs_usdfrom daily djoin mkt_prices mkton d.txn_date = mkt.mkt_dateand d.contract_address = mkt.contract_addresswhere mkt.symbol != 'WETH' --- exclude due to issues with getting the correct values), daily_total as (