zyroqclassic-olive
    Updated 2024-12-10
    WITH claim_txs AS (
    SELECT
    block_timestamp,
    tx_id,
    signers[0] AS fee_payer,
    instruction:accounts[4] AS claimant,
    amount
    FROM solana.core.fact_events
    INNER JOIN solana.core.fact_transfers
    USING(block_timestamp, tx_id)
    WHERE succeeded
    AND block_timestamp > '2024-12-10'
    AND fact_events.program_id = 'disGCfSiJKFigEphfou4PGHn1rukMfbs9cg9GpTM6oe'
    AND substr(utils.udf_base58_to_hex(fact_events.instruction:data), 3, 16) = '4eb1627bd215bb53' -- New Claim
    AND fact_transfers.mint = 'MEFNBXixkEbait3xn9bkm8WsJzXtVsaJEn4c8Sam21u'
    AND (fact_transfers.tx_to = instruction:accounts[4] -- claimant
    OR fact_transfers.tx_to = instruction:accounts[3]) -- to
    AND NOT fact_transfers.tx_to = fact_transfers.tx_from
    )

    SELECT
    DATE_TRUNC('hour', block_timestamp) AS hour,
    claimant,
    SUM(amount) AS total_claimed,
    SUM(SUM(amount)) OVER (PARTITION BY claimant ORDER BY DATE_TRUNC('hour', block_timestamp)) AS cumulative_claimed
    FROM claim_txs
    GROUP BY hour, claimant
    ORDER BY hour DESC, claimant, total_claimed DESC;
    QueryRunArchived: QueryRun has been archived