SocioCryptoStats copy
    Updated 2023-06-16
    -- forked from Stats @ https://flipsidecrypto.xyz/edit/queries/229f55b1-3964-4dbd-afc3-cbdaba6ef313

    -- forked from Stats @ https://flipsidecrypto.xyz/edit/queries/ace6d27a-9990-4d6d-ba7f-bb8b6842d177

    SELECT platform,
    avg(amount_in/amount_out) as "Average of Exch. Rate",
    median(amount_in/amount_out) as "Median of Exch. Rate",
    avg(gas_used) as "Average of Gas Used",
    median(gas_used) as "Median of Gas Used",
    count(DISTINCT a.tx_hash) as "Number of Swaps",
    count (DISTINCT a.sender) as "Number of Swappers"
    FROM ethereum.core.ez_dex_swaps a
    LEFT JOIN ethereum.core.fact_transactions b
    on a.tx_hash = b.tx_hash
    WHERE token_in ilike '{{token0_address}}' AND token_out ilike '{{token1_address}}'
    AND amount_out >0
    AND a.block_timestamp >= current_date-{{past_days}}
    AND platform != 'curve' --excluded as it has a problem in WETH/USDC convertion rate
    GROUP BY 1
    ORDER BY 4
    Run a query to Download Data