dannyamahTotal Spins
    Updated 2025-03-30
    WITH token_won AS (
    SELECT
    COUNT(DISTINCT tx_hash) AS spins,
    COUNT(DISTINCT tx_hash) * 0.1 AS total_apt_spent,
    COUNT(DISTINCT event_data:spinner) AS spinners
    FROM aptos.core.fact_events
    WHERE event_type = '0xb588e7842f7fca80cf6d92eeb7a05db0dce6af5e02248374fb4498d96ea23236::spin::SpinEvent'
    AND success = TRUE
    ),

    latest_token_price AS (
    SELECT
    token_address,
    price,
    ROW_NUMBER() OVER (PARTITION BY token_address ORDER BY hour DESC) AS rn
    FROM aptos.price.ez_prices_hourly
    WHERE token_address = '0x1::aptos_coin::AptosCoin' -- Fix operator and ensure it's for APT
    )

    SELECT
    t.spins,
    t.spinners,
    t.total_apt_spent,
    t.total_apt_spent * p.price AS total_spin_amount_usd
    FROM token_won t
    JOIN latest_token_price p
    ON p.rn = 1

    Last run: 3 months ago
    SPINS
    SPINNERS
    TOTAL_APT_SPENT
    TOTAL_SPIN_AMOUNT_USD
    1
    408837261340883.7217092.447
    1
    34B
    29s