elsinaTotal fees collected
    Updated 2022-08-01
    with price as (
    select
    hour::date as d,
    symbol,
    avg(price) as price
    from ethereum.core.fact_hourly_token_prices
    where
    hour::date >= '2022-06-01' and
    symbol in ('REVV', 'WETH')
    group by 1, 2
    ),
    -- credit smbanaie
    currency as (
    select
    block_timestamp::date as date,
    count(*) as "count",
    sum("count") over (order by date) as cumulative_count,
    sum((raw_amount/pow(10, 18)) * price) as fees,
    sum(fees) over (order by date) as cumulative_fees,
    'WETH' as currency
    from
    polygon.core.fact_token_transfers, price
    where
    origin_to_address = '0xf715beb51ec8f63317d66f491e37e7bb048fcc2d' and --- Contract Address
    to_address in ('0x8de9c5a032463c561423387a9648c5c7bcc5bc90', '0x5b3256965e7c3cf26e11fcaf296dfc8807c01073') and --- Polygon Fee Collectors for OpenSea
    origin_function_signature = '0xbbbfa60c' and
    contract_address = '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619' and
    date = d and
    symbol = 'WETH'
    group by 1

    union all

    select
    block_timestamp::date as date,
    count(*) as "count",
    Run a query to Download Data