binhachonFLOOR Tokens - #2
    Updated 2022-07-02
    with stake_unstake as (
    select
    block_timestamp,
    case when origin_function_signature = '0xd866c9d8' then 'Stake' else 'Unstake' end as type,
    case when type = 'Stake' then from_address else to_address end as user_address,
    raw_amount/1e9 as amount
    from ethereum.core.ez_token_transfers
    where contract_address = lower('0xf59257E961883636290411c11ec5Ae622d19455e')
    and block_timestamp::date >= getdate() - interval'90 days' --tx_hash in ('0xdd402385fd9b70a5e9e112e475a077bad417e70652f7b499e3f474021f9429a8', '0xb9d9a61716a6164f1400ce8d6c9ec6d79143641b1767036df26a19758c2bd997')
    and origin_function_signature in ('0x990966d5', '0xd866c9d8')
    and from_address != '0x0000000000000000000000000000000000000000'
    )
    select
    date_trunc('day', block_timestamp) as time,
    sum(case when type = 'Stake' then amount else -amount end) as volume,
    sum(volume) over (order by time) as total_staked_amount
    from stake_unstake
    group by 1
    Run a query to Download Data