boomer77opensea vs foundation vol
    Updated 2022-04-23
    with raw as (SELECT block_timestamp, tx_id, event_platform, tx_currency, price, case
    when event_platform = 'opensea' and tx_currency is null then 'WETH'
    else tx_currency end as tx,
    platform_fee, creator_fee
    from ethereum.nft_events
    where date(block_timestamp) >= CURRENT_DATE - 90 and event_platform in ('opensea') and event_type = 'sale'),

    foundation as (SELECT date_trunc('day', block_timestamp) as dt,
    'foundation' as platform,
    count(distinct tx_hash) as tx_count,
    sum(event_inputs:f8nFee/1e18) as platform_fee,
    sum(event_inputs:creatorFee/1e18) as creator_fee,
    sum(event_inputs:ownerRev/1e18) as owner_rev,
    (creator_fee+platform_fee+owner_rev) as volume
    from ethereum_core.fact_event_logs
    where contract_address = '0xcda72070e455bb31c7690a170224ce43623d0b6f' and event_name = 'ReserveAuctionFinalized' and date(block_timestamp) >= CURRENT_DATE - 90
    group by 1),

    opensea as (select date_trunc('day', block_timestamp) as dt, event_platform, count(distinct tx_id) as tx_count, sum(price) as volume, sum(platform_fee) as platform_fee, sum(creator_fee) as creator_fee
    from raw
    where tx = 'WETH'
    group by 1,2)

    select a.dt, a.volume as foundation_vol, b.volume as opensea_volume
    from foundation a
    left join opensea b on a.dt = b.dt
    Run a query to Download Data