Token Evaluations System
AIQ Evaluations and Token Processing System Documentation

This documentation provides a comprehensive overview of how the AIQ system processes, evaluates, and manages cryptocurrency tokens across various stages. The system combines market data analysis, technical indicators, and AI-powered evaluations to provide insights on tokens and generate trading signals.
System Overview
The AIQ platform follows these main workflows:
Token Discovery and Intake: Tokens are discovered through monitoring services, user searches, or direct submission
Data Collection: Multiple data fetchers gather information from various sources
Evaluation Process: Tokens undergo evaluation against configurable criteria
Scoring and Decision Making: AI models and rule-based checks determine token quality and trading signals
Token Status Management: Tokens are categorized based on evaluation results
Core Evaluation Engine
Evaluation Types
The system supports three primary evaluation types:
Status Evaluation (
ConfigType.STATUS): Evaluates token quality and viabilityBuy Evaluation (
ConfigType.BUY): Determines if a token is a good buying opportunitySell Evaluation (
ConfigType.SELL): Analyzes if a token should be sold
Evaluation Entry Points
The main entry point for token evaluation is evaluateTokenConfig, which directs to the appropriate evaluation type:
Each evaluation type follows a similar pattern but has specific processing logic for the evaluation results.
Core Evaluation Logic
The evaluateTokenWithType function provides the shared evaluation framework:
Sets up logging context
Initializes a
TokenDataFetcherto gather dataEnsures required data is available
Calculates market cap for token categorization
Fetches appropriate evaluation configurations
Checks for recent evaluations to avoid redundant processing
Processes each pending evaluation configuration
Returns statistics on evaluation results
Check Processing
For each evaluation configuration, the system:
Runs all configured checks against gathered data
Calculates an internal score based on weighted results
Requests an AI-generated score using LLMs
Combines scores to determine the final result
Saves evaluation results to the database
Processes the results according to the evaluation type
Check Result Processing
The processResults function is central to the evaluation system:
Key aspects of result processing:
Weight Calculation: Checks have weighted importance in the overall score
Required Checks: Some checks are required; failing them fails the entire evaluation
AI Analysis: The system requests AI-generated analysis for holistic assessment
Score Combination: Internal and AI scores are averaged for a final score
Threshold Application: Different thresholds apply based on evaluation type
Value Comparison Logic
The compareValues function implements the core comparison logic for checks:
The system supports several comparison modes:
Range-based comparisons: Check if value falls within a specified range
Greater-than-or-equal comparisons: Check if value β₯ threshold
Less-than-or-equal comparisons: Check if value β€ threshold
The getPercScore function converts raw values to percentage scores (0-100) based on the comparison mode, allowing for nuanced scoring rather than binary pass/fail assessment.
Post-Evaluation Processing
Each evaluation type has specific result processing:
Status Evaluation Processing
For status evaluations:
If passed, the token is queued for buy evaluation
For test tokens, processing is limited to a single status approval
Buy Evaluation Processing
For buy evaluations:
If passed, the token is queued for execution and status is set to ACTIVE
Buy execution messages are sent to applicable users
Sell Evaluation Processing
For sell evaluations:
If passed, sell execution messages are created for applicable users
Sell reason is recorded as "bad performance evaluation"
Result Persistence
The saveResultToHistory function stores evaluation results:
This function:
Maps config type to evaluation result type
Creates a database record with full evaluation details
Includes check-level results for diagnostics
Records metrics for system monitoring
Key Components
1. Token Discovery and Processing
New Token Calls (newTokenCall.ts)
This service handles the creation of new tokens and token calls:
The function:
Accepts token information (address, ticker, optional name)
Records the source of the token (e.g., USER, BIRDEYE, DEXSCREENER)
Creates the token record if it doesn't exist
Queues token for evaluation
Returns basic token data
Processing Token Sources (processTokenSources.ts)
This file contains functions for processing tokens from various sources:
processTokenSources: Processes tokens from monitoring servicesprocessBoostSources: Processes tokens from DexScreener boosts
Both functions filter out already processed tokens to avoid duplication, then create new token calls for unique discoveries.
Token Monitors
Several monitoring services continuously discover new tokens:
BirdEye Monitor (
birdeyeMonitor.ts): Monitors BirdEye API for:New tokens
Trending tokens
High-liquidity tokens
DexScreener Monitor (
dexscreenerMonitor.ts): Monitors DexScreener for:Tokens with active boost campaigns
Twitter Monitor (
twitterMonitor.ts): Monitors Twitter for:Token mentions from selected accounts
2. Data Collection and Management
TokenDataFetcher (TokenDataFetcher.ts)
This class handles fetching and caching data for token evaluation:
The class:
Fetches data from multiple sources (BirdEye, DexScreener, etc.)
Caches responses to avoid redundant API calls
Provides typed access to different data categories
Implements data expiration to ensure freshness
Candle Aggregation (candleAggregator.ts)
This module processes price candle data for technical analysis:
The function:
Takes raw price data points
Extracts the most recent hour as 1-minute candles for detailed analysis
Aggregates the previous 23 hours as hourly candles
Returns both arrays in time-ascending order
3. Token Evaluation Process
Core Evaluators
The system uses two core evaluator classes:
CoreStatusEvaluator (
CoreStatusEvaluator.ts): Base class for evaluating token statusCoreTradeEvaluator (
CoreTradeEvaluator.ts): Base class for evaluating buy/sell signals
Both follow a similar pattern:
Gather required data via
TokenDataFetcherRun configured checks against the data
Calculate internal score based on check results
Request AI score via LLM
Combine scores and determine final result
Save evaluation results to database
Token-Specific Evaluators
Two specialized evaluator classes extend the core evaluators:
TokenStatusEvaluator (
TokenStatusEvaluator.ts): Evaluates token qualityTokenTradeEvaluator (
TokenTradeEvaluator.ts): Evaluates trading opportunities
Both classes:
Load appropriate configuration based on market cap category
Support both core (default) and degen (customized) configurations
Override configurations based on user preferences
Apply appropriate checks for each evaluation type
Check Registry
The system includes many individual check functions, such as:
narrative.ts: Evaluates token narrative strengthpriceTrendPrediction.ts: Predicts price movement directionbuyToSellMaxRatio1h.ts: Checks buy/sell volume ratioliquidity.ts: Evaluates token liquiditymarketRegime.ts: Determines market conditionspriceChangePercent1h.ts: Checks price change percentagepriceDrawdown.ts: Evaluates price drops from highs
Each check:
Takes a configuration and a
TokenDataFetcherinstanceExtracts relevant data points
Performs calculations
Returns a
CheckResultwith score, value, and pass/fail status
4. AI-Powered Analyses
The system uses AI models for complex analyses:
Narrative Analysis (getNarrative.ts)
Evaluates token narratives using LLMs:
The function:
Creates a prompt describing the token
Sends the prompt to OpenAI API
Parses the JSON response
Returns a score (0-100) and explanation
AI Prompts (prompts.ts)
Contains prompt templates for AI services:
getNarrativePromptMessages: Generates prompts for evaluating token narrativesgetTokenStatusScorePromptMessages: Generates prompts for overall token evaluationgetPriceTrendPredictionPromptMessages: Generates prompts for price trend analysis
Each template:
Includes detailed system instructions
Formats token data appropriately
Provides examples to guide the AI response
Specifies expected output format
5. Token Status Management
Token Status Updater (tokenStatusUpdater.ts)
Manages token status transitions:
The function:
Updates token status based on evaluation results
Manages dormant counter for inactive tokens
Automatically rejects tokens after multiple dormant evaluations
Token Data Services (tokenData.ts)
Provides functions for retrieving token data:
getTokenWithEvaluationResult: Retrieves tokens with their evaluation resultsgetTokensByStatus: Retrieves tokens filtered by statusgetPriceSnapshot: Retrieves token price snapshotssortTokens: Helper function for consistent token sorting
6. Queue System (queues.ts)
queues.ts)The queue system orchestrates asynchronous processing:
The service:
Creates and manages Bull MQ queues
Provides methods for adding jobs to queues
Sets up schedulers for periodic tasks
Supports retry logic and error handling
Key queues include:
evaluateTokenInitDataFetching: Initial evaluation of discovered tokensevaluateTokenFetchedData: Evaluation after data fetchingevaluateBuy: Evaluation for buy signalsevaluateSell: Evaluation for sell signals
7. Token Search (tokenSearcher.ts)
tokenSearcher.ts)Provides search functionality for tokens:
The function:
Accepts search parameters (id, address, symbol)
Attempts to find existing token
Creates new token if not found and source exists
Fetches overview data for context
Returns token and overview information
8. WebSockets Subscription Manager (WebsocketsSubscriptionManager.ts)
WebsocketsSubscriptionManager.ts)Manages real-time data subscriptions:
The service:
Manages WebSocket subscriptions via Redis pub/sub
Allows subscribing to token price feeds
Supports unsubscribing when monitoring ends
Configuration Framework
The system uses a flexible configuration framework:
Market Cap Categories
Tokens are categorized by market cap:
Nanocap: < $100K
Microcap: < $1M
Smallcap: < $10M
Midcap: < $100M
Largecap: < $1B
Megacap: > $1B
Check Configuration
Each check is configurable with:
Threshold: Target value to compare against
Weight: Importance in overall score (0-100)
Required: Whether failing this check automatically fails evaluation
Disabled: Whether to skip this check
Operator: How to compare value against threshold (GTE or LTE)
Range: Optional min/max range for comparison
Core and Degen Modes
Two configuration modes:
Core Mode: Standard configurations managed by system
Degen Mode: User-customizable configurations for advanced users
Key Workflows
Token Discovery Workflow:
Monitoring service finds new token
newTokenCallcreates/updates token recordToken is queued for evaluation
Data fetchers gather token information
Evaluation determines token status
Token Evaluation Workflow:
Load appropriate configuration
Fetch required data
Run checks against data
Calculate internal score
Request AI score
Combine scores and determine result
Update token status
Save evaluation results
Trading Signal Workflow:
Token selected for evaluation
Technical and market checks performed
AI analysis requested for price trend
Buy/sell signals generated based on results
Signal results saved and potentially acted upon
Error Handling and Resilience
The system implements several resilience features:
Queue-based processing with retries
Data caching to reduce API dependency
Fallback mechanisms for missing data
Error tracking and logging
Special handling for unavailable data errors
Tolerance for test tokens
Metrics tracking for monitoring system health
Database Models
Key database models include:
Token: Core token informationTokenPrice: Historical price dataDataFetcherResponse: Cached responses from data sourcesEvaluationResult: Results of token evaluationsEvaluationResultDetails: Detailed check results
Getting Started for New Developers
Understand the core evaluation pipeline in
evaluators/index.ts:How configurations are loaded
How checks are executed
How results are processed
How AI integration works
Explore the check system:
How individual checks work
How checks are configured
How the comparison logic in
compareValuesworksHow results are aggregated
Study the result processing functions:
processStatusEvaluationsprocessBuyEvaluationsprocessSellEvaluations
Examine how results are persisted:
saveResultToHistoryMetrics tracking
Advanced Topics
Once familiar with the core system, explore:
Custom check development
Configuration management
AI prompt optimization
Performance tuning of data fetchers
Enhancing comparison operators and scoring methods
Conclusion
The AIQ Evaluations and Token Processing system is a sophisticated platform combining market data analysis, technical indicators, and AI-powered evaluations. It provides a flexible, configurable framework for discovering, analyzing, and evaluating cryptocurrency tokens, supporting both automated and user-driven workflows. The system's core strengths lie in its modular check system, configurable evaluation pipeline, and integration of machine learning for holistic assessment.
Last updated