MLDZMNprice2
    Updated 2023-08-25
    with base as (SELECT
    *,
    row_number()over(partition by origin_from_address order by block_timestamp asc) as n
    from ethereum.core.ez_token_transfers
    where contract_address = lower('0xae7ab96520de3a18e5e111b5eaab095312d7fe84')
    and from_address = '0x0000000000000000000000000000000000000000'
    and symbol = 'stETH'
    and block_timestamp >= current_date - interval '12 months'
    )

    select
    date_trunc('month', block_timestamp) as date,
    count(distinct origin_from_address) as total_users,
    count(distinct case when n=1 then origin_from_address else null end) as new_users,
    count(distinct case when n!=1 then origin_from_address else null end) as old_users,
    old_users/total_users*100 as retention_rate,
    avg(token_price) as "Avg price",
    min(token_price) as "Min price",
    max(token_price) as "Max price"
    from base
    group by 1
    Run a query to Download Data