jackguydex - agg 3
    Updated 2023-03-03
    with tab1 as (
    SELECT *
    FROM ethereum.core.dim_labels
    --WHERE label LIKE '%inch%'
    --WHERE address LIKE lower('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
    --AND address like '%0x1111%'
    WHERE address_name LIKE '1inch: general contract'
    ), tab2 as (
    SELECT DISTINCT tx_hash
    FROM ethereum.core.fact_event_logs
    WHERE CONTRACT_ADDRESS in (SELECT address from tab1)
    ), tab3 as (
    SELECT *
    FROM ethereum.core.ez_dex_swaps
    LIMIT 100
    )

    SELECT
    PLATFORM,
    sum(AMOUNT_IN_USD) as volume_usd,
    count(DISTINCT tx_hash) as swaps,
    count(DISTINCT origin_from_address) as active_users
    FROM ethereum.core.ez_dex_swaps
    WHERE tx_hash in (
    SELECT tx_hash
    FROM ethereum.core.fact_event_logs
    WHERE contract_address LIKE lower('0x1111111254EEB25477B68fb85Ed929f73A960582')
    ) and amount_in_usd < 2 * amount_out_usd
    GROUP BY 1
    Run a query to Download Data