Specterdistribution of tx withdraw
    Updated 2025-02-09

    WITH AvaxPrice AS (
    SELECT
    TRUNC(hour, 'day') AS date,
    AVG(price) AS price_usd
    FROM avalanche.price.ez_prices_hourly
    WHERE token_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    GROUP BY date
    ),
    Events AS (
    SELECT
    e.block_timestamp,
    e.tx_hash,
    e.decoded_log:avaxAmount / 1e18 AS amount,
    e.decoded_log:user AS user,
    e.event_name,
    (e.decoded_log:avaxAmount / 1e18) * p.price_usd AS amount_usd
    FROM avalanche.core.ez_decoded_event_logs e
    LEFT JOIN AvaxPrice p
    ON TRUNC(e.block_timestamp, 'day') = p.date
    WHERE e.contract_address = '0x2b2c81e08f1af8835a78bb2a90ae924ace0ea4be'
    AND e.event_name IN ('Redeem')
    ),
    TransactionDistribution AS (
    SELECT
    user,
    COUNT(DISTINCT tx_hash) AS tx_count,
    SUM(amount_usd) AS total_amount_usd
    FROM Events
    GROUP BY user
    )

    -- Distribution by Transaction Count (Number of transactions)
    SELECT
    CASE
    WHEN tx_count < 3 THEN '< 3 transactions'
    Last run: 3 months ago
    TX_COUNT_DISTRIBUTION
    TOTAL_STAKERS
    1
    3-5 transactions220
    2
    5-10 transactions49
    3
    < 3 transactions7012
    4
    > 10 transactions57
    4
    102B
    449s