0xHaM-dFees copy
    Updated 2024-05-09
    -- forked from hess / Fees @ https://flipsidecrypto.xyz/hess/q/blZ-l4FMTnz3/fees

    with zk_import as ( select * from (
    SELECT
    livequery.live.udf_api (
    'https://api.dune.com/api/v1/query/3145394/results?api_key=nPlMJ4JjTsMZcIo0C6kGSt5rpbcoXujU') as resp)
    ,
    table(FLATTEN(parse_json(resp:data:"result":"rows"))))
    ,
    chains as (
    select TO_TIMESTAMP(value:"date") as date,
    'Zksync' as chain,
    'WETH' as symbol,
    value:"avg_fee"::string as tx_fee
    from zk_import a join ethereum.core.dim_dates b on a.value:"date" = b.date_day
    -- where MONTH_NAME_SHORT = '{{Month_Name}}'
    where date >= current_date() - 31
    AND date < current_date()
    UNION
    select date(block_timestamp) as date,
    'Sei' as chain,
    'SEI' as symbol,
    (split(fee,'usei')[0]/pow(10,6)) as tx_fee
    from sei.core.fact_transactions a join ethereum.core.dim_dates b on a.block_timestamp::date = b.date_day
    -- where MONTH_NAME_SHORT = '{{Month_Name}}'
    -- and block_timestamp::date >= '2023-11-01'
    where date >= current_date() - 31
    AND date < current_date()
    and TX_SUCCEEDED = 'true'
    and split(fee,'usei')[0]/pow(10,6) != 0

    UNION
    select date(block_timestamp) as date,
    'Arbitrum' as chain,
    'WETH' as symbol,
    tx_fee
    QueryRunArchived: QueryRun has been archived