omer93silo weekly
    Updated 2024-07-15
    WITH relevant_txs AS (
    SELECT DISTINCT tx_id
    FROM sei.core.fact_msg_attributes
    WHERE attribute_key = '_contract_address'
    AND attribute_value = 'sei1e3gttzq5e5k49f9f5gzvrl0rltlav65xu6p9xc0aj7e84lantdjqp7cncc'
    AND tx_succeeded = 'true'
    AND block_timestamp::Date >= '2024-01-15'
    ),
    burn_amt AS (
    SELECT
    tx_id,
    (attribute_value / POW(10, 6)) AS burn_amount
    FROM sei.core.fact_msg_attributes
    WHERE attribute_key = 'utoken_refunded'
    AND tx_id IN (SELECT tx_id FROM relevant_txs)
    AND block_timestamp::Date >= '2024-01-15'
    ),
    un_user AS (
    SELECT
    DATE_TRUNC('week', block_timestamp) AS weekly,
    COUNT(DISTINCT a.tx_id) * -1 AS burn_txs,
    SUM(burn_amount) * -1 AS un_amount,
    COUNT(DISTINCT attribute_value) * -1 AS burn_users,
    SUM(COALESCE(SUM(burn_amount), 0)) OVER (ORDER BY DATE_TRUNC('week', block_timestamp)) AS cumulative_burn_volumes,
    AVG(burn_amount) AS avg_burn_amount
    FROM sei.core.fact_msg_attributes a
    JOIN burn_amt b ON a.tx_id = b.tx_id
    WHERE block_timestamp::Date >= '2024-01-15'
    AND attribute_key = 'fee_payer'
    GROUP BY 1
    ),
    mint_amt AS (
    SELECT
    tx_id,
    attribute_value / POW(10, 6) AS mint_amount
    FROM sei.core.fact_msg_attributes
    QueryRunArchived: QueryRun has been archived