vendettauniswap
    Updated 2023-02-25
    with tb1 as ( select BLOCK_TIMESTAMP, TX_HASH, ACTION, LIQUIDITY_PROVIDER, POOL_NAME, case when TOKEN0_SYMBOL = 'WETH' then AMOUNT0_ADJUSTED when TOKEN1_SYMBOL = 'WETH' then AMOUNT1_ADJUSTED end as Amount
    from ethereum.uniswapv3.ez_lp_actions where (TOKEN0_SYMBOL = 'WETH' or TOKEN1_SYMBOL = 'WETH') and BLOCK_TIMESTAMP::DATE >= '2022-07-01' and BLOCK_TIMESTAMP::DATE < CURRENT_DATE and Amount > 0 ),
    tb2 as ( select date_trunc('day', block_timestamp) as day, sum(Amount) as "eth amount", count(distinct TX_HASH) as "d txCount", count(distinct LIQUIDITY_PROVIDER) as "Depositors" from tb1
    where ACTION = 'INCREASE_LIQUIDITY' group by 1), W as ( select date_trunc('day', block_timestamp) as day, sum(Amount) as "eth amount", count(distinct TX_HASH) as "w txCount", -- count(distinct TX_HASH) as "w txCount",
    count(distinct LIQUIDITY_PROVIDER) as "Withdrawers" from tb1 where ACTION = 'DECREASE_LIQUIDITY' group by 1 ), tb3 as (select tb2.day, --, tb3 as (select tb2.day,
    case WHEN tb2.day >= '2022-09-01' and tb2.day < '2022-09-15' THEN 'Two weeks before the merge' WHEN tb2.day < '2022-09-01' THEN 'Before merge' ELSE 'After merge' end as Period,
    tb2."eth amount" AS "Deposit eth amount", W."eth amount" AS "Withdraw eth amount", tb2."eth amount" - W."eth amount" as "Net eth amount", case when "Net eth amount"<0 then '-' else '+' end as "Net Amount status",
    W."w txCount" AS "Withdraw TX number", tb2."d txCount" AS "Deposit TX number", W."Withdrawers", tb2."Depositors" from tb2 join W on tb2.day = W.day order by 1 asc ) --= W.day order by 1 asc )
    select * ,sum("Deposit eth amount") over(order by day asc) as "Deposit eth amount commulative" ,sum("Net eth amount") over(order by day asc) as "Net eth commulative"
    ,sum("Withdraw eth amount") over(order by day asc) as "Withdraw eth amount commulative" ,(select sum("Withdraw eth amount") from tb3 where Period = 'Two weeks before the merge' ) as "Withdraw eth amount TWoweeks"
    ,(select sum("Deposit eth amount") from tb3 where Period = 'Two weeks before the merge' ) as "Deposit eth amount TWoweeks" --as "Deposit eth amount TWoweeks"
    ,((select sum("Withdraw eth amount") from tb3 where Period = 'Two weeks before the merge' ) /(select sum("Deposit eth amount") from tb3 where Period = 'Two weeks before the merge' )) as "w/d"
    from tb3 order by day asc --from tb3 order by day asc


    Run a query to Download Data