i_danAvax VS Base: Stablecoins
    Updated 2024-11-27
    WITH base_tokens AS (
    SELECT
    block_timestamp
    , symbol_in AS symbol
    , CASE WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NOT NULL THEN ((amount_in_usd+amount_out_usd)/2)
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NULL THEN NULL
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NOT NULL THEN amount_out_usd
    WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NULL THEN amount_in_usd
    ELSE NULL END AS amount
    FROM base.defi.ez_dex_swaps
    UNION ALL
    SELECT
    block_timestamp
    , symbol_out AS symbol
    , CASE WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NOT NULL THEN ((amount_in_usd+amount_out_usd)/2)
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NULL THEN NULL
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NOT NULL THEN amount_out_usd
    WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NULL THEN amount_in_usd
    ELSE NULL END AS amount
    FROM base.defi.ez_dex_swaps
    ),

    avax_tokens AS (
    SELECT
    block_timestamp
    , symbol_in AS symbol
    , CASE WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NOT NULL THEN ((amount_in_usd+amount_out_usd)/2)
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NULL THEN NULL
    WHEN amount_in_usd IS NULL AND amount_out_usd IS NOT NULL THEN amount_out_usd
    WHEN amount_in_usd IS NOT NULL AND amount_out_usd IS NULL THEN amount_in_usd
    ELSE NULL END AS amount
    FROM avalanche.defi.ez_dex_swaps
    UNION ALL
    QueryRunArchived: QueryRun has been archived