Eman-RazUSDC Liquidity on Each Platform
    Updated 2024-04-01
    with inflow as (with tab1 as (select block_timestamp, from_address, to_address, tx_hash, raw_amount/pow(10,6) as Volume
    from base.core.fact_token_transfers
    where contract_address='0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'),

    tab2 as (select platform, pool_address, pool_name
    from base.defi.dim_dex_liquidity_pools)

    select platform as "Platform", sum(volume) as "Input Volume"
    from tab1 left join tab2 on tab1.to_address=tab2.pool_address
    where pool_address is not null and from_address not ilike '0x0000000%'
    and block_timestamp::date<=current_date-1
    group by 1
    order by 1),

    outflow as (with tab1 as (select block_timestamp, from_address, to_address, tx_hash, raw_amount/pow(10,6) as Volume
    from base.core.fact_token_transfers
    where contract_address='0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'),

    tab2 as (select platform, pool_address, pool_name
    from base.defi.dim_dex_liquidity_pools)

    select platform as "Platform", sum(volume) as "Output Volume"
    from tab1 left join tab2 on tab1.from_address=tab2.pool_address
    where pool_address is not null and to_address not ilike '0x0000000%'
    and block_timestamp::date<=current_date-1
    group by 1
    order by 1)

    select inflow."Platform" as "Platform", "Input Volume"-"Output Volume" as "Net Volume"
    from inflow left join outflow on inflow."Platform"=outflow."Platform"
    where "Input Volume">"Output Volume"
    Auto-refreshes every 3 hours
    QueryRunArchived: QueryRun has been archived