Decentralized Exchanges

Some common tasks relating to Decentralized Exchanges and DeFi.

Jupiter Exchange Aggregator

Users can fetch data from the Jupiter Exchange Aggregatorarrow-up-right. 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
    }
}

Raydium

Raydiumarrow-up-right 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/SOLarrow-up-right, and converting to its USD value using a Pyth task with SOL/USD.

// SLERF/USD using Raydium and Pyth
{
  lpExchangeRateTask: {
    raydiumPoolAddress: "AgFnRLUScRD2E4nWQxW73hdbSN7eKEUb2jHX7tx9YTYc", // SLERF/SOL Pool
  },
},
{
  multiplyTask: {
    job: {
      tasks: [
        {
          oracleTask: {
            pythAddress: "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG", // SOL/USD
            pythAllowedConfidenceInterval: 1.2,
          }
        }
      ]
    }
  }
}

Orca

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

Meteora

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

Sanctum

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

Uniswap

Uniswaparrow-up-right 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 V2arrow-up-right and Uniswap V3arrow-up-right, 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.exchangearrow-up-right protocol, on Corearrow-up-right, 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.networkarrow-up-right, a Uniswap V3 clone also on Core.

OpenBook

The OpenBookarrow-up-right 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