For the complete documentation index, see llms.txt. This page is also available as Markdown.

Decentralized Exchanges

Some common tasks relating to Decentralized Exchanges and DeFi.

Jupiter Exchange Aggregator

Users can fetch data from the Jupiter Exchange Aggregator. This can be an effective tool for quoting assets traded on Solana.

// KMNO/USD with 2% slippage
{
  jupiterSwapTask: {
    inTokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
    outTokenAddress: "KMNo3nJsBXfcpJTVhZcXLW7RmTwTt4GVFE7suUBo9sS", // KMNO
    slippage: 2.0,
    apiKey: "${JUPITER_API_KEY}",
  },
}

Supply the matching non-empty value with the execution request:

const response = await gateway.fetchSignaturesConsensus({
  // ...feed request fields
  variableOverrides: {
    JUPITER_API_KEY: process.env.JUPITER_API_KEY!,
  },
});

JUPITER_API_KEY is a conventional name, not a reserved fallback. The override key must exactly match the placeholder in apiKey. If the placeholder is unresolved, the task fails before contacting Jupiter. If apiKey is omitted or empty, the task uses the oracle's configured Jupiter API key when one is available.

Do not hardcode an API key in the job definition. See Data Feed Variable Overrides for request scope and trust-boundary guidance, Pyth authentication for its different compatibility fallback, and the JupiterSwapTask reference for every field.

Raydium

Raydium is an active hub for DeFi activity on Solana, and Switchboard allows you to quote assets from its Concentrated and Standard pools. All you need is a pool address.

The following is an example using Raydium to quote SLERF/SOL, and converting to its USD value using a Pyth task with SOL/USD.

Orca

You can pull exchange rates from Orca (Solana AMM). Plugging in any of these pools will yield the resulting price.

Meteora

You can read in prices from Meteora using a meteoraSwapTask. You can use it to pull in exchange rates from DLMM pools and standard pools.

Sanctum

The LST protocol on Solana, Sanctum, is also supported. This task is useful for users who want to bring fair Solana LST prices into their protocols through Switchboard.

Uniswap

Uniswap is probably the most recognized AMM that exists. Switchboard enables users to pull prices from the protocol, along with clones on other chains.

Using the uniswapExchangeRateTask, users can bring in exchange rates from Uniswap V2 and Uniswap V3, along with any Uniswap-ABI-compatible protocols (/Uniswap clones on other chains).

Here's an example of a Uniswap Task pulling data from the glyph.exchange protocol, on Core, which is a Uniswap V2 fork.

In the same task for Uniswap V3, a Quoter address should also be passed. Here's an example from corex.network, a Uniswap V3 clone also on Core.

OpenBook

The OpenBook codebase was the first major CLOB on Solana, and we support it through the serumSwapTask . The following is an example of pulling a SOL/USDC price:

Last updated