binhachonForefront Treasury
    Updated 2022-03-27
    with treasury_transaction as (
    select
    block_timestamp,
    symbol,
    amount
    from ethereum.udm_events
    where to_address = lower('0x2Fb9F0ef424b24a8D293999298F392a33Fe6A8b5')
    and block_timestamp::date > '2021-03-01'
    and symbol in ('USDC', 'FF', 'ETH')
    and amount is not null
    union all
    select
    block_timestamp,
    symbol,
    -amount
    from ethereum.udm_events
    where from_address = lower('0x2Fb9F0ef424b24a8D293999298F392a33Fe6A8b5')
    and block_timestamp::date > '2021-03-01'
    and symbol in ('USDC', 'FF', 'ETH')
    and amount is not null
    ),
    treasury_balance as (
    select
    date_trunc('week', block_timestamp) as time,
    symbol,
    sum(amount) as weekly_inflow,
    sum(case when amount < 0 then -amount else 0 end) as weekly_payment_from_treasury
    from treasury_transaction
    group by time, symbol
    ),
    price_list as (
    select
    date_trunc('week', hour) as time,
    symbol,
    avg(price) as price
    from ethereum.token_prices_hourly
    Run a query to Download Data