Skip to content

Step 3: Validate Your Config with Zod

Location: absinthe-adapters/packages/common/src/types/schema.ts

Before your indexer runs, it validates the config using a Zod schema. This ensures your config is correct and prevents runtime errors.

const dexProtocolSchema = z.object({
  type: z.enum([
    ProtocolType.UNISWAP_V2,
    ProtocolType.UNISWAP_V3,
    ProtocolType.COMPOUND,
    ProtocolType.AAVE,
    ProtocolType.CURVE,
    ProtocolType.BALANCER,
    ProtocolType.IZUMI,
  ]),
  chainId: z.number(),
  toBlock: z.number(),
  protocols: z.array(protocolConfigSchema),
});

What does this do?

  • type: Must be one of the allowed protocol types (Uniswap V2, V3, etc).
  • chainId: Must be a number (EVM chain ID).
  • toBlock: Must be a number (block height).
  • protocols: Must be an array of valid pool configs (validated by protocolConfigSchema).

If your config doesn't match this schema, the app will throw an error at startup.