Skip to content

Step 4: Map Config to Runtime Objects

Location: absinthe-adapters/packages/common/src/utils/validateEnv.ts

After validation, your config is mapped to runtime objects with chain metadata and RPC URLs.

const dexProtocols: ValidatedDexProtocolConfig[] = configResult.data.dexProtocols.map(dexProtocol => {
  const chainId = dexProtocol.chainId;
  const chainKey = getChainEnumKey(chainId);
  if (!chainKey) {
    throw new Error(`${chainId} is not a supported chainId.`);
  }
  const chainName = ChainName[chainKey];
  const chainShortName = ChainShortName[chainKey];
  const chainArch = ChainType.EVM;
  const gatewayUrl = GatewayUrl[chainKey];
  const rpcUrl = getRpcUrlForChain(chainId, envResult.data);
  return {
    type: dexProtocol.type,
    gatewayUrl: gatewayUrl,
    toBlock: dexProtocol.toBlock,
    protocols: dexProtocol.protocols as ProtocolConfig[],
    chainArch: chainArch,
    chainId: chainId,
    chainShortName: chainShortName,
    chainName: chainName,
    rpcUrl: rpcUrl,
  };
});

What's happening here?

For each DEX protocol in your config:

  • It looks up chain metadata (name, short name, arch, gateway URL, RPC URL).
  • It returns a new object with all the original config plus the derived metadata.

This makes it easy for the indexer to know which chain, which pools, and how to connect.