maybeyonasthor_staking_dist
    Updated 2022-05-23
    with
    vthor_data as (
    select
    block_timestamp,
    tx_hash,
    event_name,
    case when event_name = 'Withdraw' then event_inputs:to::string else event_inputs:from::string end as user,
    case when event_name = 'Withdraw' then event_inputs:amount/pow(10,18) else event_inputs:value/pow(10,18) end as thor_amount,
    case when event_name = 'Withdraw' then event_inputs:balance/pow(10,18) else event_inputs:time/pow(10,18) end as vthor_amount
    from ethereum_core.fact_event_logs
    where contract_address = '0x815c23eca83261b6ec689b60cc4a58b54bc24d8d'
    and event_name in ('Deposit','Withdraw')
    -- and tx_hash = '0x5938cc5db7022788fb176c799fb7b1593ddd26807af8eee326f96120161f141e' -- deposit
    -- and tx_hash = '0xbc68eb5dee27b2b984c15ff5d5da52603fb730f4dc7746428d68b638ad39d6fc' -- withdraw
    ),
    daily as (
    select
    user,
    count(
    case when event_name = 'Deposit' then tx_hash else null end
    ) as deposit_txs,
    count(
    case when event_name = 'Withdraw' then tx_hash else null end
    ) as withdraw_txs,
    sum(
    case when event_name = 'Deposit' then thor_amount else 0 end
    ) as thor_deposited,
    sum(
    case when event_name = 'Withdraw' then thor_amount else 0 end
    ) as thor_withdrawn,
    sum(
    case when event_name = 'Deposit' then vthor_amount else 0 end
    ) as vthor_minted,
    sum(
    case when event_name = 'Withdraw' then vthor_amount else 0 end
    ) as vthor_burnt,
    Run a query to Download Data