hbd19942023-11-19 09:58 AM
    Updated 2023-11-19
    with base as (

    SELECT
    'Avalanche' as network,
    BLOCK_TIMESTAMP,
    TX_HASH,
    ORIGIN_FROM_ADDRESS,
    ORIGIN_TO_ADDRESS,
    CONTRACT_ADDRESS,
    POOL_NAME,
    TOKEN_IN,
    SYMBOL_IN,
    AMOUNT_IN,
    AMOUNT_IN_USD,
    TOKEN_OUT,
    SYMBOL_OUT,
    AMOUNT_OUT,
    AMOUNT_OUT_USD,
    coalesce(AMOUNT_IN_USD,AMOUNT_OUT_USD) as swap_volume
    from avalanche.defi.ez_dex_swaps
    where PLATFORM ilike '%uniswap%')


    select
    network as "Network",
    date_trunc('week',BLOCK_TIMESTAMP::date) as "Date",
    count(distinct tx_hash) as "Swap Transactions",
    count(*) as "Swaps",
    lag("Swaps") over (partition by "Network" order by "Date") as "Previous Month Swaps",
    (("Swaps" - "Previous Month Swaps") / "Previous Month Swaps" * 100) as "Change Rate (%)",
    case
    when "Previous Month Swaps" > "Swaps" then '🔴'
    when "Previous Month Swaps" < "Swaps" then '🟢'
    when "Previous Month Swaps" = "Swaps" then '⚪'
    end as "Status",
    "Status" || ' | ' || "Change Rate (%)" as "Change Rate Status",
    Run a query to Download Data