rezarwzDaily Trading Fee past x days
    Updated 2024-06-28
    -- forked from Daily Trading Fee @ https://flipsidecrypto.xyz/edit/queries/ab06a0f7-bd58-4157-b25b-cfe12939b5ee
    with all_launch as (
    SELECT
    INNER_INSTRUCTION:instructions [2] :parsed:info:newAccount :: string as sol_owner
    FROM
    solana.core.fact_events ev
    WHERE
    program_id = 'degenhbmsyzLpJUwwrzjsPyhPNvLurBFB4k1pBWSoxs'
    and INNER_INSTRUCTION:instructions [0] :parsed:type :: string = 'createAccount'
    and INNER_INSTRUCTION:instructions [1] :parsed:type :: string = 'initializeMint2'
    and SUCCEEDED = 'TRUE'
    and block_Timestamp >= '2024-05-17 01:15:51.000'
    and block_timestamp >= TIMESTAMPADD(
    day,
    - {{past_x_days}},
    CURRENT_TIMESTAMP
    )
    )
    SELECT
    BLOCK_TIMESTAMP :: date as date,
    sum(AMOUNT * 0.01) as "Daily Total Trading Fee",
    sum(sum(AMOUNT * 0.01)) over(
    ORDER BY
    BLOCK_TIMESTAMP :: date asc
    ) as "Total Trading Fee",
    sum(count(DISTINCT tx_id)) over(
    ORDER BY
    BLOCK_TIMESTAMP :: date asc
    ) as "Total # of Trades",
    count(DISTINCT tx_id) as "Daily # of Trades"
    from
    solana.core.fact_transfers
    where
    block_Timestamp >= '2024-05-17 01:15:51.000'
    and MINT = 'So11111111111111111111111111111111111111112'
    and (
    QueryRunArchived: QueryRun has been archived