Queries
Overview
A query is a valid SQL statement that defines who qualifies for rewards through an incentive. Examples of queries could be buy and hold, trading competitions, liquidity provisioning, or program specific queries to your protocol.
Queries are the foundation of Torque's reward distribution system, allowing you to target specific users based on on-chain behavior, metrics, or custom logic.
Query Requirements
Basic Structure
All queries must return at least two columns:
address- The wallet address of the recipientscoreoramount- A numeric value used for allocation
Recurring Incentive Parameters
To use a query with a recurring incentive, you must include two time-based parameters and return at least two columns
startDate- The beginning of the evaluation periodendDate- The end of the evaluation period
Columns
address- the address of the user's score or allocated amountscore or amount- the calculated metric for determining the rewarded amount (rebate) or score (leaderboard / raffles)
How Queries Work
Torque's engine uses your query to power the entire incentive lifecycle:
Calculation - Runs your query to identify qualifying addresses
Allocation - Applies distribution logic based on the scores/amounts returned and the distribution mechanics
Distribution - Allocates tokens to an onchain distributor upon funding.
The specific behavior depends on your incentive type (Leaderboard, Raffle, Rebate, or Direct).
Example: Rewarding Token Holders
Let's say you're a token creator who wants to reward users for holding your token. Here's how you'd set it up:
Step 1: Select or Create Your Query
Choose a pre-defined query from the library or write your own SQL.

Step 2: Configure Parameters
Set your custom parameters along with the required time parameters:
startDate- Epoch start dateendDate- Epoch end datetoken_mint- Your token's mint addressmin_balance- Minimum holding threshold

Step 3: Test Your Query
Run the query to verify the results look correct and return the expected addresses and scores.

Step 4: Create Your Incentive
Click "New Incentive" and complete the setup flow, selecting your query and configuring your distribution settings.
Last updated
