mondovswaps
    Updated 2023-06-22
    with avalanche_swaps_from_usdc as (
    SELECT count(DISTINCT tx_hash) as total_swaps, count(DISTINCT sender) as total_swappers,
    'Avalanche' as chain, 'from USDC' as type, sum(amount_in_usd) as total_volume
    FROM avalanche.core.ez_dex_swaps
    WHERE lower(symbol_in) = 'usdc'
    ),

    avalanche_swaps_to_usdc as (
    SELECT count(DISTINCT tx_hash) as total_swaps, count(DISTINCT sender) as total_swappers,
    'Avalanche' as chain, 'to USDC' as type, sum(amount_in_usd) as total_volume
    FROM avalanche.core.ez_dex_swaps
    WHERE lower(symbol_out) = 'usdc'
    ),

    polygon_swaps_from_usdc as (
    SELECT count(DISTINCT tx_hash) as total_swaps, count(DISTINCT sender) as total_swappers,
    'Polygon' as chain, 'from USDC' as type, sum(amount_in_usd) as total_volume
    FROM polygon.core.ez_dex_swaps
    WHERE lower(symbol_in) = 'usdc'
    ),

    polygon_swaps_to_usdc as (
    SELECT count(DISTINCT tx_hash) as total_swaps, count(DISTINCT sender) as total_swappers,
    'Polygon' as chain, 'to USDC' as type, sum(amount_in_usd) as total_volume
    FROM polygon.core.ez_dex_swaps
    WHERE lower(symbol_out) = 'usdc'
    ),

    arbitrum_swaps_from_usdc as (
    SELECT
    -- GET(decoded_log, 'tokenIn') AS token_in,
    count(DISTINCT tx_hash) as total_swaps, count(DISTINCT origin_from_address) as total_swappers,
    'Arbitrum' as chain, 'from USDC' as type, sum(GET(decoded_log, 'amountIn')/power(10, decimals)) as total_volume
    FROM arbitrum.core.ez_decoded_event_logs l
    JOIN arbitrum.core.dim_contracts c ON GET(l.decoded_log, 'tokenIn') = c.address
    WHERE (GET(decoded_log, 'tokenIn') = lower('0xaf88d065e77c8cC2239327C5EDb3A432268e5831')
    Run a query to Download Data