1. Overview & Schema – Absinthe Docs
Skip to content

1. Overview & Schema

Purpose

This adapter indexes Uniswap V2 pool activity. It tracks:

  • LP token balance changes (Transfer events)
  • Swaps (Swap events)

The adapter provides a foundation for building DeFi analytics, yield farming rewards, and trading activity tracking.

Core Structure

export default registerAdapter({
  name: 'uniswap-v2',
  semver: '0.0.1',
  schema: z.object({
    poolAddress: ZodEvmAddress,
    trackSwaps: z.boolean().optional(),
    trackLP: z.boolean().optional(),
  }).refine((p) => !!p.trackSwaps || !!p.trackLP),
  build: ({ params }) => { ... }
})

Key Components

registerAdapter

What it does: Registers this adapter with the Absinthe framework.

Why it matters: This makes the adapter discoverable and configurable through the standard Absinthe interface.

schema Validation

Purpose: Validates user-supplied configuration parameters.

Key requirements:
  • poolAddress: Must be a valid EVM address (the Uniswap V2 pool contract)
  • trackSwaps or trackLP: At least one tracking mode must be enabled
  • Uses Zod for runtime type validation
Example configuration:
{
  "poolAddress": "0x1234567890123456789012345678901234567890",
  "trackSwaps": true,
  "trackLP": true
}

build Function

What it defines:
  • Which blockchain logs to listen for
  • How to process those logs when they occur
  • Event emission logic for downstream processing

Key principle: The build function returns a processor configuration that tells the system exactly what data to collect and how to transform it.

What You'll Learn

This tutorial will walk you through:

  1. How to configure log filtering for optimal performance
  2. Redis caching strategies to minimize RPC calls
  3. LP position tracking via Transfer events
  4. Swap event processing for trade analytics
  5. Best practices for building robust DeFi adapters