hbd1994Monthly Average FLOW Balance of Wallets
    Updated 2022-11-29
    with withdraw as
    (
    with maintable as (
    select
    a.BLOCK_TIMESTAMP,
    a.TX_ID,
    b.Authorizers[0]::string,
    b.PAYER,
    a.EVENT_DATA:amount as amount,
    a.EVENT_DATA:from::string as "User"
    from flow.core.fact_events a
    join flow.core.fact_transactions b on a.tx_id = b.tx_id
    where a.EVENT_CONTRACT = 'A.1654653399040a61.FlowToken'
    and a.EVENT_TYPE = 'TokensWithdrawn'
    and a.TX_SUCCEEDED = true)

    select
    date_trunc('month',block_timestamp::date) as "Date",
    "User",
    count(distinct TX_ID) as "Number of Withdrawal Transactions",
    count(*) as "Number of Withdrawal Events",
    sum(amount) as "Withdrawals Volume"
    from maintable
    group by 1,2),
    deposit as
    (
    with maintable as (
    select
    a.BLOCK_TIMESTAMP,
    a.TX_ID,
    b.Authorizers[0]::string,
    b.PAYER,
    a.EVENT_DATA:amount as amount,
    a.EVENT_DATA:to::string as "User"
    from flow.core.fact_events a
    Run a query to Download Data