zakkisyedEthereum: MDAO Treasury Balance
    Updated 2023-02-13
    with
    inbound_tx as (
    select
    sum(amount / 1e6) as amount_in,
    date_trunc(month, block_timestamp) as dt
    from
    ethereum.core.ez_token_transfers
    where
    to_address = '0x4fafb87de15cff7448bd0658112f4e4b0d53332c'
    group by
    2
    ),
    outbound_tx as (
    select
    sum(amount / 1e6) as amount_out,
    date_trunc(month, block_timestamp) as dt
    from
    ethereum.core.ez_token_transfers
    where
    from_address = '0x4fafb87de15cff7448bd0658112f4e4b0d53332c'
    group by
    2
    )
    select
    t1.amount_in,
    t2.amount_out,
    case when amount_out != null
    then amount_in - t2.amount_out
    else amount_in
    end as current_balance,
    from
    inbound_tx t1
    left join outbound_tx t2 on t1.dt = t2.dt
    Run a query to Download Data