hessDaily Woofi
    Updated 2023-11-16
    with woofi as ( select block_timestamp,
    tx_hash,
    origin_from_address,
    pool_name,
    symbol_in,
    symbol_out,
    case when amount_in_usd is null then amount_out_usd
    when amount_out_usd is null then amount_in_usd
    when amount_in_usd>=amount_out_usd then amount_in_usd
    when amount_out_usd>amount_in_usd then amount_out_usd end as amount_usd
    from avalanche.defi.ez_dex_swaps
    where platform = 'woofi'
    )

    select trunc(block_timestamp,'week') as date,
    count(DISTINCT(tx_hash)) tx,
    count(*) as swaps,
    swaps/tx as "Avg Swap per Tx",
    count(DISTINCT(origin_from_address)) as users,
    sum(amount_usd) as usd_volume,
    sum(usd_volume) over (order by date asc) as "Cumulative Volume",
    avg(amount_usd) as "Avg Volume Per User",
    tx/users as "Avg Tx Per User",
    avg(usd_volume) over (order by date rows between 1 preceding and 0 following) as avg_7D,
    avg(usd_volume) over (order by date rows between 2 preceding and 0 following) as avg_14D,
    avg(usd_volume) over (order by date rows between 4 preceding and 0 following) as avg_30D
    from woofi
    where amount_usd is not null
    group by 1

    Run a query to Download Data