Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Configuration

Use ConfigParams to initialize config via createConfig or the SpandexProvider component.

Params

providers

Aggregator[]

List of active provider aggregators. Each provider has a factory function that returns an Aggregator instance with its configuration. You can include multiple instances for the same provider to test alternate configurations.

FactoryAPI Key Required?Config Docs
zeroXyesView
fabricnoView
kyberswapnoView
odosnoView
lifinoView
relaynoView

Example:

import { fabric, zeroX } from "@spandex/core";
 
const providers = [
  zeroX({
    apiKey: "YOUR_0X_API_KEY",
    timeoutMs: 12_000,
    negotiatedFeatures: ["integratorFees"],
  }),
  fabric({
    appId: "YOUR_FABRIC_APP_ID",
  }),
];

proxy

AggregatorProxy

Proxy instance used to delegate quote fetching to a server endpoint. When proxy is set, you cannot set providers or options in the same config.

Example:

import { createConfig, proxy } from "@spandex/core";
 
const config = createConfig({
  proxy: proxy({ pathOrUrl: "https://example.com/api/quotes" }),
});

options (optional)

AggregationOptions

options.deadlineMs

number | undefined

Maximum duration for the entire aggregation process before aborting pending requests. Defaults to 15,000 ms. Set a lower value for faster responses with potentially fewer quotes.

options.numRetries

number | undefined

Number of retry attempts per provider. Defaults to 1.

options.initialRetryDelayMs

number | undefined

Initial delay before retrying failed requests (exponential backoff applied). Defaults to 100 ms.

options.integratorFeeAddress

Address | undefined

Address that should receive the integrator fee. Use this if your application collects fees on swaps from end users. Only applicable if the provider supports integrator fees. Some providers may require a custom API key tied to your integrator fee address.

options.integratorSwapFeeBps

number | undefined

Swap fee for the integrator (in basis points). Only applicable if the provider supports integrator fees.

options.integratorSurplusBps

number | undefined

Surplus share for the integrator (in basis points). Only applicable if the provider supports surplus sharing.


clients (optional)

PublicClient[] | ((chainId: number) => PublicClient | undefined)

A list of viem/wagmi clients or a lookup function to get the client for a specific chain ID. This is used to fetch on-chain data for quote simulation and validation. If not provided, getQuotes, getQuote, and simulation utilities will fail. If you wish to only get quotes without validating onchain, use getRawQuotes instead. When using SpandexProvider, the wagmi clients from the provider will be used automatically.