Ranjit-Yadavuniswap merge 5
    Updated 2022-10-14
    with sushipools as (select * from ethereum.core.dim_dex_liquidity_pools where platform = 'uniswap-v3'),

    table1 as (
    select block_timestamp,
    tx_hash,
    origin_from_address as Liquidity_Provider,
    contract_address as Pool_Address,
    event_inputs:amount0::numeric as RawAmount0,
    event_inputs:amount1::numeric as RawAmount1,
    case when event_name = 'Mint' then 'Add Liquidity' when event_name = 'Burn' then 'Remove Liquidity' else null end as Action_Type
    from ethereum.core.fact_event_logs
    where block_timestamp >= '2022-09-01' and block_timestamp <= '2022-09-30'
    and contract_address in (select Pool_Address from sushipools)
    and action_type is not null),

    table2 as (
    select t1.tx_hash,
    t1.block_timestamp,
    t1.Liquidity_Provider,
    t1.Pool_Address,
    t1.Action_Type,
    t1.RawAmount0 as RawAmount0,
    t1.RawAmount1 as RawAmount1,
    t2.pool_name,
    t2.token0 as Token0_Address,
    t2.token1 as Token1_Address,
    t3.symbol as Token0_Symbol,
    t3.amount as Token0_Amount,
    t3.amount_usd as Token0_USD_Amount,
    t4.symbol as Token1_Symbol,
    t4.amount as Token1_Amount,
    t4.amount_usd as Token1_USD_Amount
    from table1 t1 left join sushipools as t2 on t1.Pool_Address = t2.Pool_Address
    left join ethereum.core.ez_token_transfers as t3 on t1.tx_hash = t3.tx_hash and t3.contract_address = t2.token0 and t3.raw_amount = t1.RawAmount0 and t3.block_timestamp >= '2022-09-01' and t3.block_timestamp <= '2022-09-30'
    left join ethereum.core.ez_token_transfers as t4 on t1.tx_hash = t4.tx_hash and t4.contract_address = t2.token1 and t4.raw_amount = t1.RawAmount1 and t4.block_timestamp >= '2022-09-01' and t4.block_timestamp <= '2022-09-30'),

    Run a query to Download Data