KuramaStargate - Monthly swap volume by chain
    Updated 2023-01-10
    with all_tx_swap_BSC as (select distinct tx_hash as tx_hash, topics[0] as topics1, contract_address from bsc.core.fact_event_logs
    where contract_address in ('0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c')
    AND topics[0] in ('0xfb2b592367452f1c437675bed47f5e1e6c25188c17d7ba01a12eb030bc41ccef')
    ),

    all_bsc as (
    select date, 'BSC' as chain, sum(amount) as total_amount
    from (
    select topics1,
    date_trunc('day',block_timestamp) as date, (raw_amount/pow(10,18)) as amount
    from bsc.core.fact_token_transfers a
    left join all_tx_swap_BSC b
    on a.tx_hash = b.tx_hash
    where (from_address in ('0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c')
    or to_address in ('0x9aa83081aa06af7208dcc7a4cb72c94d057d2cda','0x98a5737749490856b401db5dc27f522fc314a4e1','0x4e145a589e4c03cbe3d28520e4bf3089834289df','0x7bfd7f2498c4796f10b6c611d9db393d3052510c'))
    and a.contract_address in ('0x55d398326f99059ff775485246999027b3197955','0xe9e7cea3dedca5984780bafc599bd69add087d56','0xd17479997f34dd9156deef8f95a52d81d265be9c','0x3f56e0c36d275367b8c502090edf38289b3dea0d')
    and topics1 = '0xfb2b592367452f1c437675bed47f5e1e6c25188c17d7ba01a12eb030bc41ccef'
    and a.tx_hash in (select tx_hash from all_tx_swap_BSC)
    )
    group by date, chain),


    all_tx_swap_eth as (select distinct tx_hash as tx_hash, topics[0] as topics1, contract_address from ethereum.core.fact_event_logs
    where contract_address in ('0xdf0770df86a8034b3efef0a1bb3c889b8332ff56','0x38ea452219524bb87e18de1c24d3bb59510bd783','0x0faf1d2d3ced330824de3b8200fc8dc6e397850d', '0xfa0f307783ac21c39e939acff795e27b650f6e68','0x692953e758c3669290cb1677180c64183cee374e','0xe8f55368c82d38bbbbdb5533e7f56afc2e978cc2','0x590d4f8a68583639f215f675f3a259ed84790580')
    AND topics[0] in ('0xfb2b592367452f1c437675bed47f5e1e6c25188c17d7ba01a12eb030bc41ccef')
    ),



    daily_eth_6 as (
    select date, 'ETH' as chain, sum(amount) as total_amount from (
    select topics1, date_trunc('day',block_timestamp) as date, a.tx_hash,
    raw_amount/pow(10,6) as amount
    from ethereum.core.fact_token_transfers a
    left join all_tx_swap_eth b
    on a.tx_hash = b.tx_hash
    Run a query to Download Data