cypherForefront payments usdc vs ff
    Updated 2022-04-19
    with data as (select
    date(date_trunc('day', block_timestamp)) as date,
    sum(case contract_name
    when 'FFToken' then event_inputs:value/1e18
    when 'USDC' then event_inputs:value/1e6
    end) as amount,
    contract_name as coin
    from ethereum.events_emitted
    where block_timestamp >= '2022-1-1'
    and tx_to_address = lower('0x2fb9f0ef424b24a8d293999298f392a33fe6a8b5')
    and event_name = 'Transfer'
    group by date, coin
    order by date),

    ff_price as (select
    date(date_trunc('day', hour)) as date,
    avg(price) as avg_price
    from ethereum.token_prices_hourly
    where token_address = lower('0x7E9D8f07A64e363e97A648904a89fb4cd5fB94CD')
    and date >= '2022-1-1'
    group by date
    order by date),

    temp as (select * from data
    full outer join ff_price using (date)),

    usd_values as (select *,
    case coin
    when 'FFToken' then amount * avg_price
    when 'USDC' then amount * 1
    end as usd_value
    from temp)

    select coin, sum(usd_value) as total_paid
    from usd_values
    Run a query to Download Data