banbannard$THOR Staking Wallets 2
    Updated 2022-05-22
    with base as (select origin_from_address as staker,
    min(date_trunc('day', block_timestamp)) as first_tx
    from ethereum_core.fact_token_transfers
    where --tx_hash = '0x6b298e69474080bd5f8a1bebb2562110a72a58e3655265feb7d90a0ddbf19df0'
    origin_function_signature = '0x6e553f65'
    and contract_address = '0xa5f2211b9b8170f694421f2046281775e8468044'
    and origin_to_address = '0x815c23eca83261b6ec689b60cc4a58b54bc24d8d'
    group by 1),

    base2 as (select date_trunc('day', balance_date) as day,
    count(distinct(user_address)) as number_of_holders
    from ethereum.erc20_balances
    where contract_address = '0xa5f2211b9b8170f694421f2046281775e8468044'
    and balance > 0
    and day >= '2022-05-04'
    group by 1
    )

    select first_tx,
    count(distinct(staker)) as count_staker,
    sum(count_staker) over (order by first_tx) as cumulative_count_staker,
    number_of_holders,
    cumulative_count_staker/number_of_holders * 100 as percentage_staked
    from base a
    join base2 b
    on a.first_tx = b.day
    where first_tx >= '2022-05-04'
    group by 1,4


    Run a query to Download Data