Skip to main content

Documentation Index

Fetch the complete documentation index at: https://beta.docs.sqd.dev/llms.txt

Use this file to discover all available pages before exploring further.

Track dynamically created contracts with evmDecoder().
factory(config: FactoryConfig): Factory
Parameters:
  • address: Factory contract address or array of addresses (required)
  • event: Factory creation event ABI or filtered event object (required)
    • Simple format: AbiEvent<T> - Capture all factory events
    • Filtered format: { event: AbiEvent<T>, params: {...} } - Filter by indexed parameters
    Events should be specified using the same approach as evmDecoder() itself uses.
  • parameter: Extract child address (event) => string (required)
  • database: A factory store that persists the list of known child contracts (required)
Example:
import { factory, contractFactoryStore } from "@subsquid/pipes/evm";

const factoryInstance = factory({
  address: "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  event: factoryAbi.events.PoolCreated,
  parameter: "pool",
  database: contractFactoryStore({ path: "./pools.sqlite" }),
});
Filtered factory events:
factory({
  address: "0x1f98431c8ad98523631ae4a59f267346ea31f984",
  event: {
    event: factoryAbi.events.PoolCreated,
    params: {
      token0: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", // WETH
    },
  },
  parameter: "pool",
  database: contractFactoryStore({ path: "./weth-pools.sqlite" }),
});
Only indexed event parameters can be used in the params object. Another way to look at it is that parameter values should be available as event topics. Reference.

contractFactoryStore

Create an SQLite factory database: an object used to persist the list of child contracts in a fork-aware way. For now, only SQLite-based factory databases are supported.
contractFactoryStore(config: { path: string }): FactoryDatabase