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
    tx_hash,
    contract_address,
    case when contract_address = '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490' then '3CRV' else 'UST' end as symbol,
    sum(case when contract_address = '0x6c3f90f043a72fa612cbac8115ee7e52bde6e490' then raw_amount/1e18 else raw_amount/1e6 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 from_address = lower('0xCEAF7747579696A2F0bb206a14210e3c9e6fB269')
    and contract_address in ('0x6c3f90f043a72fa612cbac8115ee7e52bde6e490', '0xa693b19d2931d498c5b318df961919bb4aee87a5')
    group by 1, 2, 3
    ),
    provider_with_amount as (
    select
    provider,
    symbol,
    sum(amount) as amount
    from provider
    left join remove_liquidity on (provider.tx_hash = remove_liquidity.tx_hash)
    group by 1, 2
    )
    select * from provider_with_amount

    Run a query to Download Data