adalhiwBTC Collected by Aave Treasury : Optimism vs Arbitrum and Ethereum
    Updated 2022-09-09
    with eth as (
    select
    date_trunc('day', block_timestamp) as date,
    sum(amount) as fees_collected,
    'Ethereum' as chain
    from ethereum.core.ez_token_transfers
    where to_address = lower('0x464C71f6c2F760DdA6093dCB91C24c39e5d6e18c')
    and contract_address = lower('0x9ff58f4fFB29fA2266Ab25e75e2A8b3503311656')
    and date >= '2022-06-01'
    group by date),

    arb as (
    select
    date_trunc('day', block_timestamp) as date,
    sum(raw_amount / pow(10, 8)) as fees_collected,
    'Arbitrum' as chain
    from arbitrum.core.fact_token_transfers
    where to_address = lower('0x053D55f9B5AF8694c503EB288a1B7E552f590710')
    and contract_address = lower('0x078f358208685046a11C85e8ad32895DED33A249')
    and date >= '2022-06-01'
    group by date),

    opt as (
    select
    date_trunc('day', block_timestamp) as date,
    sum(raw_amount / pow(10, 8)) as fees_collected,
    'Optimism' as chain
    from optimism.core.fact_token_transfers
    where to_address = lower('0xB2289E329D2F85F1eD31Adbb30eA345278F21bcf')
    and contract_address = lower('0x078f358208685046a11C85e8ad32895DED33A249')
    and date >= '2022-06-01'
    group by date)

    select date, fees_collected, chain from eth
    union select date, fees_collected, chain from arb
    union select date, fees_collected, chain from opt

    Run a query to Download Data