mariyaContractually Obligated
    Updated 2022-03-13
    with tb1 as (
    select
    date_trunc('day', first_transaction_stamp) as first_transaction_date,
    sender as new_users
    from (
    select
    distinct msg_value:sender as sender,
    min(block_timestamp) as first_transaction_stamp
    from terra.msgs
    WHERE block_timestamp >= CURRENT_DATE - 90
    and tx_id is not null
    group by 1
    )
    where first_transaction_date > current_date - 90
    group by 1,2)

    select
    tx_to[0] as protocl_Address,
    labels.address_name AS protocol_name,
    count(distinct tx_from[0]) as new__users,
    count(tx_id) as transactions
    from terra.transactions
    LEFT JOIN terra.labels labels
    ON tx_to[0] = labels.address
    where tx_from[0] in (select new_users from tb1)
    and block_timestamp >= CURRENT_DATE - 90
    and protocol_name is not null
    group by protocl_Address,protocol_name
    order by new__users DESC
    limit 20
    Run a query to Download Data