mlhUntitled Query
    Updated 2022-09-19
    WITH

    usdc_pools AS (
    SELECT pool_address
    , trim(replace(replace(pool_name, 'SLP', ''), 'LP', '')) AS _trimmed_pool_name
    , token0
    , token1
    , split(_trimmed_pool_name, '-')[0] AS token0_symbol
    , split(_trimmed_pool_name, '-')[1] AS token1_symbol
    , _trimmed_pool_name AS pool_name
    FROM ethereum.core.dim_dex_liquidity_pools
    WHERE platform = 'sushiswap'
    AND '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' IN (token0, token1)
    ),
    deposits AS (
    SELECT ev.tx_hash
    , ev.block_timestamp
    , ev.block_number
    , ev.origin_from_address AS liquidity_provider
    , ev.contract_address AS pool_address
    , p.token0 AS token0_address
    , t0.symbol AS token0_symbol
    , ev.event_inputs['amount0']::BIGINT / power(10, t0.decimals) AS token0_amount
    , p.token1 AS token1_address
    , t1.symbol AS token1_symbol
    , ev.event_inputs['amount1']::BIGINT / power(10, t1.decimals) AS token1_amount

    , (CASE WHEN token0_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' THEN token0_amount
    WHEN token1_address = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' THEN token1_amount END) AS usdc_amount

    , 2*usdc_amount AS deposit_amount_usdc
    FROM ethereum.core.fact_event_logs AS ev
    LEFT JOIN ethereum.core.dim_dex_liquidity_pools AS p
    Run a query to Download Data