binhachonUntitled Query
    Updated 2022-05-08
    with provider as (
    select
    tx_hash,
    event_inputs:provider::string as provider
    from ethereum_core.fact_event_logs
    where block_timestamp::date >= '2022-05-07'
    and block_timestamp::date <= '2022-05-08'
    and contract_address = lower('0xCEAF7747579696A2F0bb206a14210e3c9e6fB269')
    and event_name like 'RemoveLiquidity%'
    ),
    remove_liquidity as (
    select
    to_address,
    contract_address,
    -- case when contract_address = '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490' then '3CRV' else 'UST' end as symbol,
    sum(case when contract_address = '0xa693b19d2931d498c5b318df961919bb4aee87a5' then raw_amount/1e6 else raw_amount/1e18 end) as amount
    from ethereum_core.fact_token_transfers
    where block_timestamp::date >= '2022-05-07'
    and block_timestamp::date <= '2022-05-08'
    and tx_hash in (select tx_hash from provider)
    and to_address not in (lower('0xCEAF7747579696A2F0bb206a14210e3c9e6fB269'), '0xa79828df1850e8a3a3064576f380d90aecdd3359', '0x0000000000000000000000000000000000000000')
    -- and contract_address in ('0x6c3f90f043a72fa612cbac8115ee7e52bde6e490', '0xa693b19d2931d498c5b318df961919bb4aee87a5')
    group by 1, 2
    )
    select remove_liquidity.*, case when contract_address = '0xa693b19d2931d498c5b318df961919bb4aee87a5' then 'UST' else symbol end as symbol from remove_liquidity left join ethereum_core.dim_contracts on (address = contract_address)
    Run a query to Download Data