Iacomusnew_users poly
    Updated 2023-05-15
    -- forked from new_users @ https://flipsidecrypto.xyz/edit/queries/cd7e3a72-0fa8-4367-8b6f-fdf4e6e0e8a7
    --polygon.core.ez_token_transfers
    WITH existing_users as
    (SELECT distinct origin_from_address
    FROM polygon.core.ez_token_transfers
    where DATE(BLOCK_TIMESTAMP) < '2022-05-01'
    and origin_to_address IN('0xc36442b4a4522e871399cd717abdd847ab11fe88',
    '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
    '0xe592427a0aece92de3edee1f18e0157c05861564',
    '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45',
    '0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b')),

    new_users_int as
    (SELECT origin_from_address as new_user, block_timestamp,
    CASE
    WHEN origin_to_address = '0xc36442b4a4522e871399cd717abdd847ab11fe88' THEN 'positions v3'
    WHEN origin_to_address = '0x5ba1e12693dc8f9c48aad8770482f4739beed696' THEN 'multicall'
    WHEN origin_to_address = '0xe592427a0aece92de3edee1f18e0157c05861564' THEN 'router v3'
    WHEN origin_to_address = '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45' THEN 'router v2'
    WHEN origin_to_address = '0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b' THEN 'router universal'
    END AS uniswap_contract
    FROM polygon.core.ez_token_transfers
    where (DATE(BLOCK_TIMESTAMP) >= '2022-05-01' AND DATE(BLOCK_TIMESTAMP) < '2023-05-01')
    and origin_to_address IN('0xc36442b4a4522e871399cd717abdd847ab11fe88',
    '0x5ba1e12693dc8f9c48aad8770482f4739beed696',
    '0xe592427a0aece92de3edee1f18e0157c05861564',
    '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45',
    '0xef1c6e67703c7bd7107eed8303fbe6ec2554bf6b')
    and origin_from_address not in (select * from existing_users)),

    new_users as
    (select *
    from
    (select new_user, block_timestamp, uniswap_contract,
    row_number() over(partition by new_user order by block_timestamp) first_use
    from new_users_int)
    Run a query to Download Data