MLDZMNTrading fee generated
    Updated 2024-04-10
    with tb1 as (select
    RECORDED_HOUR::date as day,
    CURRENCY,
    avg (price) as price_token
    from osmosis.price.ez_prices
    group by 1,2)


    SELECT
    BLOCK_DATE as day,
    sum(FEES*price_token) as "Trading fee (USD)",
    sum("Trading fee (USD)") over (order by BLOCK_DATE) as "Cumulative trading fee (USD)"


    from osmosis.defi.fact_pool_fee_day s
    left join tb1 b on s.BLOCK_DATE::date=b.day and s.CURRENCY=b.CURRENCY
    left join osmosis.core.dim_tokens t on s.CURRENCY=t.address
    where BLOCK_DATE >= '2023-01-01'
    and BLOCK_DATE < '2024-03-16'
    --and FEES*price_token<1e2
    and t.decimal is not NULL
    and t.decimal>0
    group by 1
    QueryRunArchived: QueryRun has been archived