Skip to content

Data Flow & Processing

1. Event Processing Pipeline

Blockchain Event → Subsquid Processor → Event Decoder → State Manager → API Client

Step-by-Step Process

  1. Event Detection: Subsquid processor detects relevant blockchain events
  2. Event Decoding: Raw event data is decoded using protocol-specific ABIs
  3. State Update: Protocol state is updated based on event data
  4. Balance Calculation: Time-weighted balances are calculated
  5. Price Integration: USD values are calculated using price feeds
  6. Data Transmission: Processed data is sent to Absinthe API

2. Time-Weighted Balance Tracking

Window-Based Processing

  • Configurable Windows: Balance snapshots taken at configurable intervals
  • Trigger Events: Balance updates triggered by transfers or time windows
  • Accurate Tracking: Maintains historical balance records with timestamps

Balance Calculation Example

// For a user holding 1000 LP tokens for 24 hours
const balanceWindow = {
  userAddress: '0x...',
  deltaAmount: 0, // No change in balance
  startTs: 1640995200, // Start of day
  endTs: 1641081600, // End of day
  windowDurationMs: 86400000, // 24 hours
  balanceBefore: '1000',
  balanceAfter: '1000',
  valueUsd: 5000, // Calculated USD value
};

3. Batch Processing

Optimization Features

  • Batch Size Control: Configurable batch sizes for optimal performance
  • Parallel Processing: Multiple protocols processed in parallel
  • Memory Management: Efficient memory usage with streaming processing
  • Error Recovery: Graceful handling of processing errors