MrftiDaily averages copy
    Updated 2025-05-24
    -- forked from Daily averages @ https://flipsidecrypto.xyz/studio/queries/548cb8b6-f981-4459-b5d4-08bcef447fbc

    WITH database AS (
    SELECT
    a.BLOCK_TIMESTAMP,
    a.TX_HASH,
    a.ORIGIN_FROM_ADDRESS AS "Staker",
    b.value AS "$MON Staked",
    CAST(ethereum.public.udf_hex_to_int(data) AS decimal) / 1e18 AS "$gMON minted",
    b.tx_fee AS "Fee ($MON)"
    FROM
    monad.testnet.fact_event_logs a
    JOIN monad.testnet.fact_transactions b ON a.tx_hash = b.tx_hash
    WHERE
    a.CONTRACT_ADDRESS = lower ('0x2c9C959516e9AAEdB2C748224a41249202ca8BE7')
    and a.ORIGIN_TO_ADDRESS = lower ('0x2c9C959516e9AAEdB2C748224a41249202ca8BE7')
    and a.ORIGIN_FUNCTION_SIGNATURE = '0xd5575982'
    and a.TX_SUCCEEDED = 'TRUE'
    )
    , daily_metrics AS (
    SELECT
    DATE(BLOCK_TIMESTAMP) AS "Date",
    count (distinct "Staker") as "Total Daily Stakers",
    count (distinct TX_HASH) as "Total Daily Stake tx",
    SUM("Fee ($MON)") AS "Total Daily Fee ($MON)",
    SUM("$MON Staked") AS "Total Daily $MON Staked",
    SUM("$gMON minted") AS "Total Daily $gMON minted"
    FROM database
    group by 1
    )
    SELECT
    AVG("Total Daily Stakers") AS "Average Daily Stakers",
    AVG("Total Daily Stake tx") AS "Average Daily Stake tx",
    AVG("Total Daily Fee ($MON)") AS "Average Daily Fee ($MON)",
    AVG("Total Daily $MON Staked") AS "Average Daily $MON Staked",
    QueryRunArchived: QueryRun has been archived