adriaparcerisasTransaction Fees on Osmosis 2
    Updated 2022-05-23
    with fees as (
    select
    block_timestamp,
    case when REGEXP_SUBSTR(fee,'i.*') is not null then REGEXP_SUBSTR(fee,'i.*')
    else REGEXP_SUBSTR(fee,'u.*') end as fee_name,
    tx_status,
    REPLACE(fee, fee_name, '')::decimal/pow(10,6) as fee_paid,
    tx_id
    from osmosis.core.fact_transactions
    where BLOCK_TIMESTAMP>=CURRENT_DATE-30
    )
    SELECT
    trunc(x.block_timestamp,'day') as date,
    y.msg_type as tx_type,
    sum(fee_paid) as daily_fees,
    sum(daily_fees) over (partition by tx_type order by date) as cum_fees
    from fees x
    join osmosis.core.fact_msgs y on x.tx_id=y.tx_id
    group by 1,2
    order by 1 asc, 2


    Run a query to Download Data