carlesmontala4- Who's Got The Flow?
    Updated 2022-11-28
    with depositt as (
    select event_data:to as flowuser,
    sum (event_data:amount) as Deposit_Volume
    from flow.core.fact_events
    where event_contract = 'A.1654653399040a61.FlowToken'
    and event_type = 'TokensDeposited' and tx_succeeded = 'TRUE'
    group by 1),

    withdrawt as (
    select event_data:from as flowuser,
    sum (event_data:amount) as Withdraw_Volume
    from flow.core.fact_events
    where event_contract = 'A.1654653399040a61.FlowToken'
    and event_type = 'TokensWithdrawn' and tx_succeeded = 'TRUE'
    group by 1)

    select t1.flowuser::string as Flow_Wallet,
    case when Flow_Wallet = '0x8624b52f9ddcd04a' then '$FLOW Staking Contract'
    when flow_wallet = '0x21dc51d454d46f49' then 'Coinlist CEX Withdrawal'
    when flow_wallet = '0x6a7457b796dee457' then 'Kraken CEX Hot Wallet'
    when flow_wallet = '0x5dc3fc329730c066' then 'Coinlist CEX Deposit'
    when flow_wallet = '0xb3fd4cb859ee6fef' then 'OKX CEX Hot Wallet'
    else FLOW_Wallet end as title,
    sum (deposit_volume - withdraw_volume) as Balance
    from depositt t1 join withdrawt t2 on t1.flowuser = t2.flowuser
    where t1.flowuser != 'null'
    group by 1,2
    order by 3 DESC
    limit 50
    Run a query to Download Data