Skip to content
OnchainQueries

OQ — U10 · Trading intelligence

Price is the output. The flow that produced it — who bought, on which venue, through which route, at what size — lives in decoded instruction and event data.

OQ — U10·1What you get

Every one of these is a SQL query against typed tables.

Venue share

GROUP BY program

Which programs actually filled the volume, and how that split moves over a day.

Route analysis

aggregator + AMM tables

How aggregator routes decompose into individual venue fills.

Size distribution

approx_percentile

approx_percentile over trade size to separate retail flow from everything else.

Buy/sell imbalance

count_if

count_if over the direction flag, bucketed by hour.

OQ — U10·3Example

A CTE for the hourly aggregate, then a 24-hour rolling sum over it.

rolling.sql
WITH hourly AS (  SELECT    date_trunc('hour', ts) AS hour,    sum(sol_amount) AS volume  FROM pump_fun.trade_event  WHERE ts >= {{start_time}}  GROUP BY hour)SELECT  hour,  volume,  sum(volume) OVER (    ORDER BY hour    ROWS BETWEEN 23 PRECEDING AND CURRENT ROW  ) AS rolling_24h_volumeFROM hourlyORDER BY hour;

Then widen the window.