KuramaStargate - TVL per chain - new
    Updated 2023-01-10
    with daily_bsc as (
    select date, 'BSC' as chain,
    sum(amount) as total_amount from (
    select date_trunc('day',block_timestamp) as date, tx_hash,
    case when from_address in (
    '0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c')
    then (raw_amount/pow(10,18))*(-1)
    else raw_amount/pow(10,18) end as amount
    from bsc.core.fact_token_transfers a
    where (from_address in ('0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c')
    or to_address in ('0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c'))
    and contract_address in ('0x55d398326f99059ff775485246999027b3197955','0xe9e7cea3dedca5984780bafc599bd69add087d56','0xd17479997f34dd9156deef8f95a52d81d265be9c','0x3f56e0c36d275367b8c502090edf38289b3dea0d')
    )
    group by date, chain),

    total_bsc as (select date, chain, sum(total_amount) over (order by date) as tvl
    from daily_bsc ),


    daily_eth_6 as (
    select date, 'ETH' as chain, sum(amount) as total_amount from (
    select date_trunc('day',block_timestamp) as date, tx_hash,
    case when from_address in ('0xdf0770df86a8034b3efef0a1bb3c889b8332ff56','0x38ea452219524bb87e18de1c24d3bb59510bd783') then raw_amount/pow(10,6)*(-1)
    else raw_amount/pow(10,6) end as amount
    from ethereum.core.fact_token_transfers a
    where (from_address in ('0xdf0770df86a8034b3efef0a1bb3c889b8332ff56','0x38ea452219524bb87e18de1c24d3bb59510bd783')
    or to_address in ('0xdf0770df86a8034b3efef0a1bb3c889b8332ff56','0x38ea452219524bb87e18de1c24d3bb59510bd783') )
    and contract_address in ('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48','0xdac17f958d2ee523a2206206994597c13d831ec7')
    )
    group by date, chain),

    daily_eth_18 as (
    select date, 'ETH' as chain, sum(amount) as total_amount from (
    select date_trunc('day',block_timestamp) as date, tx_hash,
    Run a query to Download Data