jp12Flash [SOL] Saga - Number of Swap Distribution
    Updated 2023-09-09
    WITH orders_per_user as (
    SELECT INNER_INSTRUCTION:instructions[1]:parsed:info:authority::string as user, COUNT(DISTINCT tx_id) as num_orders
    FROM solana.core.fact_events
    WHERE block_timestamp >= '2022-06-22' and PROGRAM_ID = '781wH11JGQgEoBkBzuc8uoQLtp8KxeHk1yZiS1JhFYKy'
    and SUCCEEDED = 'TRUE' and INNER_INSTRUCTION:instructions[1]:parsed:info:amount = '100000000'
    GROUP BY 1
    ORDER BY num_orders DESC
    )

    , num_swaps as (
    SELECT SWAPPER, COUNT(DISTINCT tx_id) as num_tx,
    CASE
    WHEN num_tx < 100 THEN '0-100'
    WHEN num_tx < 500 THEN '100-500'
    WHEN num_tx < 1000 THEN '500-1000'
    WHEN num_tx < 5000 THEN '1000-5000'
    WHEN num_tx > 5000 THEN '> 5000'
    END as type
    FROM solana.core.fact_swaps
    WHERE block_timestamp >= '2022-01-01' and SUCCEEDED = 'TRUE' and SWAPPER IN (SELECT user FROM orders_per_user)
    GROUP BY 1
    ORDER BY num_tx DESC
    )

    SELECT type, COUNT(DISTINCT SWAPPER) as num_users
    FROM num_swaps
    GROUP BY 1
    Run a query to Download Data