tomwanhhic21 uniswap pool liquidity
    Updated 2023-09-21
    with deposit as (
    select address, symbol, sum(amount) from (
    select from_address as address, symbol, sum(amount) as amount
    from ethereum.core.ez_token_transfers
    where lower(to_address) = lower('0x15E71C06244F5CaB0B1aBDb01807ca248D314BB9')
    group by 1,2
    union all
    select to_address as address, symbol, sum(amount*-1) as amount
    from ethereum.core.ez_token_transfers
    where lower(from_address) = lower('0x15E71C06244F5CaB0B1aBDb01807ca248D314BB9')
    group by 1,2
    )a group by 1,2
    ),

    withdrawal as (
    select date(block_timestamp) as day, symbol, sum(amount*-1) as withdrawal
    from ethereum.core.ez_token_transfers
    where lower(from_address) = lower('0x15E71C06244F5CaB0B1aBDb01807ca248D314BB9')
    group by 1,2
    ),

    base as (
    select date_day as day, symbol
    from
    crosschain.core.dim_dates
    cross join (select distinct symbol from deposit)
    where
    date_day >= date(2023-09-12)
    and date_day<=date(current_date())
    )

    select * from (
    select *, sum(net_change) over (partition by symbol order by day) as balance from (
    select a.day, a.symbol, coalesce(deposit,0), coalesce(withdrawal,0), coalesce(deposit,0)+coalesce(withdrawal,0) as net_change
    from base a
    left join deposit b
    Run a query to Download Data