PotLockFees on POTs vs. Donations
    Updated 2024-06-13
    WITH txns AS (
    SELECT DISTINCT
    tx_hash,
    transaction_fee AS tx_fee,
    block_timestamp
    FROM near.core.fact_transactions
    WHERE
    (tx_receiver = 'registry.potlock.near' OR
    tx_signer = 'registry.potlock.near')
    AND tx_succeeded = TRUE
    ),
    fees AS (
    SELECT
    DATE_TRUNC('month', a.block_timestamp) AS month,
    SUM(CASE WHEN a.method_name = 'register' THEN txns.tx_fee ELSE 0 END) / 1e24 AS pot_fees,
    SUM(CASE WHEN a.method_name = 'donate' THEN txns.tx_fee ELSE 0 END) / 1e24 AS donation_fees
    FROM
    near.core.fact_actions_events_function_call a
    JOIN txns ON a.tx_hash = txns.tx_hash
    WHERE
    a.method_name IN ('register', 'donate')
    GROUP BY
    month
    )
    SELECT
    month,
    pot_fees,
    donation_fees
    FROM
    fees
    ORDER BY
    month;
    QueryRunArchived: QueryRun has been archived