bluewaters_analytics2024-06-15 11:40 AM
    Updated 2024-06-15
    WITH event_data AS (
    SELECT
    a.*,
    CASE
    WHEN a.contract_address = '0x3b475f6f2f41853706afc9fa6a6b8c5df1a2724c' THEN d.decoded_value / 1e18
    WHEN a.contract_address = '0xeff77e179f6abb49a5bf0ec25c920b495e110c3b' THEN d.decoded_transfer / 1e18
    ELSE NULL
    END AS zyb_token_amount,
    CASE
    WHEN a.contract_address = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' THEN d.decoded_value / 1e18
    ELSE NULL
    END AS weth_token_amount
    FROM arbitrum.core.fact_event_logs a
    JOIN arbitrum.core.fact_decoded_event_logs d
    ON a.tx_hash = d.tx_hash
    WHERE LOWER(a.origin_to_address) = '0xeff77e179f6abb49a5bf0ec25c920b495e110c3b'
    AND a.origin_function_signature = '0xb6b55f25'
    AND a.TX_STATUS = 'SUCCESS'
    AND (d.decoded_value / 1e18 < 1e9 OR d.decoded_transfer / 1e18 < 1e9)
    )

    SELECT
    COUNT(DISTINCT tx_hash) AS total_stake_txns,
    COUNT(DISTINCT origin_from_address) AS distinct_stakers,
    SUM(zyb_token_amount) AS total_zyb_amount,
    SUM(weth_token_amount) AS total_weth_amount,
    AVG(zyb_token_amount) AS avg_zyb_amount,
    AVG(weth_token_amount) AS avg_weth_amount,
    SUM(weth_token_amount * 1564.80) AS total_weth_usd,
    SUM(zyb_token_amount * 5.06) AS total_zyb_usd,
    AVG(weth_token_amount * 1564.80) AS avg_weth_usd,
    AVG(zyb_token_amount * 5.06) AS avg_zyb_usd
    FROM event_data
    WHERE zyb_token_amount IS NOT NULL OR weth_token_amount IS NOT NULL;

    QueryRunArchived: QueryRun has been archived