Query Builder

Generate and preview SQL queries for incentive data sources

The query builder tools generate SQL queries that define what user activity an incentive tracks and how it's measured.

generate_incentive_query

Generate a SQL query for any incentive source. Set the source parameter to select the data source, then provide source-specific parameters.

Requires: authentication, active project

Common Parameters

ParameterTypeRequiredDescription
source"swap" | "bonding_curve" | "hold" | "custom_event" | "idl_instruction"YesData source for the query
confirmedbooleanNoSet to true to confirm (custom_event, idl_instruction). Omit to preview.

Token Swap Parameters

ParameterTypeDescription
tokenMintstringSPL token mint address (required)
direction"buy" | "sell" | "both"Trade direction (default: "buy")
measure"volume" | "count"What to measure
minUsdAmountnumberMinimum USD value per swap
protocolstringDEX protocol filter (e.g. Jupiter, Raydium)

Bonding Curve Parameters

ParameterTypeDescription
tokenMintstringSPL token mint address (required)
launchpad"raydium_launchlab" | "metaplex_genesis"Launchpad program (required)
direction"buy" | "sell" | "both"Trade direction (default: "buy")
measure"volume" | "count"What to measure
poolStatestringPool state address (required for raydium_launchlab)
genesisAccountstringGenesis account (required for metaplex_genesis)
minAmountInnumberMinimum purchase size in raw amount

Token Hold Parameters

ParameterTypeDescription
tokenMintstringSPL token mint address (required)
measure"balance" | "duration" | "count"What to measure
minBalancenumberMinimum token balance (required)

Custom Event Parameters

ParameterTypeDescription
customEventIdstringCustom event ID (required)
valueExpressionstringValue expression, e.g. "SUM(amount)", "COUNT(*)"
filtersstring[]WHERE conditions using field names
groupByPubkeybooleanGroup by pubkey (default: true)
orderBy"DESC" | "ASC"Sort order
limitnumberMax rows
rawQuerystringRaw SQL with {{startDate}}/{{endDate}} params

IDL Instruction Parameters

ParameterTypeDescription
instructionIdstringInstruction ID (required)
valueExpressionstringValue expression
filtersstring[]WHERE conditions
groupByFeePayerbooleanGroup by fee payer (default: true)
orderBy"DESC" | "ASC"Sort order
limitnumberMax rows
rawQuerystringRaw SQL with {{startDate}}/{{endDate}} params

preview_incentive_query

Execute a SQL query against real indexed data and preview the results before creating an incentive. The query runs asynchronously with up to 60 seconds timeout. By default, previews the last 3 complete days of data.

Requires: authentication, active project

ParameterTypeRequiredDescription
sqlQuerystringYesThe SQL query to preview
startDatestringNoISO 8601 start date (default: 3 days ago)
endDatestringNoISO 8601 end date (default: today at midnight)

Always preview your query before creating an incentive. This validates that the query produces the expected shape and data using real indexed data.

The query may be queued before it starts executing. The assistant will let you know it's waiting for results — this typically takes a few seconds but can take up to 60 seconds for complex queries.