Yousefi_1994Optimistic Sushi - Polygon weekly new user
    Updated 2022-10-26
    ----------------------------------- Polygon -----------------------------------

    with polygon_new_user as (
    select
    origin_from_address as from_address,
    min(block_timestamp) as min_block_timestamp
    from polygon.core.fact_event_logs
    where origin_from_address != '0x0000000000000000000000000000000000000000'
    and tx_status = 'SUCCESS'
    group by from_address
    having min_block_timestamp >= '2022-06-01'
    ),
    polygon_count_new_user as (
    select
    date_trunc('week', min_block_timestamp) as "Weeks",
    count(distinct from_address) as "Number of New User"
    from polygon_new_user
    group by "Weeks"
    ),
    polygon_user_transactions as (
    select
    tx_hash,
    origin_from_address as from_address,
    min(block_timestamp) as min_block_timestamp
    from polygon.core.fact_event_logs
    where origin_from_address != '0x0000000000000000000000000000000000000000'
    and origin_from_address in (select from_address from polygon_new_user)
    and tx_status = 'SUCCESS'
    group by tx_hash, from_address
    ),
    polygon_user_transactions_and_rank as (
    select
    *,
    row_number() over(partition by from_address order by min_block_timestamp) as row_num
    from polygon_user_transactions
    ),
    Run a query to Download Data