Soheil_MKUntitled Query
    Updated 2022-11-26
    WITH withdraw as (
    select
    --BLOCK_TIMESTAMP::date as date,
    EVENT_DATA:from as wallet,
    sum(EVENT_DATA:amount) as Flow_amounts
    from flow.core.fact_events
    WHERE EVENT_TYPE ='TokensWithdrawn'
    and EVENT_CONTRACT ='A.1654653399040a61.FlowToken'
    and TX_SUCCEEDED='TRUE'
    and WALLET is not null
    and wallet !='null'
    group by 1
    ),

    deposit as (
    select
    --BLOCK_TIMESTAMP::date as date,
    EVENT_DATA:to as wallet,
    sum(EVENT_DATA:amount) as Flow_amounts
    from flow.core.fact_events
    WHERE EVENT_TYPE ='TokensDeposited'
    and EVENT_CONTRACT ='A.1654653399040a61.FlowToken'
    and TX_SUCCEEDED='TRUE'
    and WALLET is not null
    and wallet !='null'
    group by 1
    )



    select
    a.wallet::varchar,
    round(sum(a.Flow_amounts-b.Flow_amounts)) as Flow_balance
    from deposit a
    join withdraw b
    on a.wallet=b.wallet
    Run a query to Download Data