nsa2000Algo1
    Updated 2022-11-19
    with pricet as (
    select block_hour::date as day,
    asset_id,
    avg (price_usd) as USDPrice
    from algorand.defi.ez_price_pool_balances
    group by 1,2)

    select swap_program,
    count (distinct tx_group_id) as Swaps_Count,
    count (distinct swapper) as Swappers_Count,
    sum (swap_from_amount*usdprice) as USD_Volume,
    avg (swap_from_amount*usdprice) as Average_USD_Volume,
    median (swap_from_amount*usdprice) as Median_USD_Volume,
    min (swap_from_amount*usdprice) as Min_USD_Volume,
    max (swap_from_amount*usdprice) as Max_USD_Volume
    from algorand.defi.fact_swap t1 join pricet t2 on t1.block_timestamp::date = t2.day and t1.swap_from_asset_id = t2.asset_id
    group by 1
    Run a query to Download Data