Symmetry Protocol
Liquidity SDK Documentation
Symmetry Liquidity SDK can be installed using yarn or npm
yarn add @symmetry-hq/liquidity-sdk
npm install @symmetry-hq/liquidity-sdk
Using the liquidity SDK is fairly simple.
import { TokenSwap } from "@symmetry-hq/liquidity-sdk";
let tokenSwap = await TokenSwap.init(
// Rpc connection
connection: Connection,
// Wallet (optional | can be provided later, using tokenSwap.setWallet() function
wallet: Wallet,
Executing swap
// load routeData based on tokenFrom, tokenTo and fromAmount
let routeData: RouteData = tokenSwap.loadSwap(
tokenFrom: PublicKey,
tokenTo: PublicKey,
fromAmount: number,
This is what RouteData looks like
type RouteData = {
fromAmount: number,
toAmount: number,
minimumReceived: number,
fromTokenId: number,
toTokenId: number,
feeUSDC: number,
swapAccounts: {
program: PublicKey,
fundState: PublicKey,
authority: PublicKey,
source: PublicKey,
destination: PublicKey,
fees: PublicKey,
tokenInfo: PublicKey,
remainingAccounts: AccountMeta[],
// generate swap instruction
let ix: TransactionInstruction = await tokenSwap
routeData: RouteData,
fromTokenAccount: PublicKey,
toTokenAccount: PublicKey,
// for sol swap, wSol token accounts should be provided.
// Get available tokens for swap
// Re-load liquidity sources(liquidity info isn't updated after TokenSwap.init())
await tokenSwap.updateLiquiditySources();
// Check liquidity in a specific fund
let liquidityInfos: {
tokenMint: string
coingeckoId: string,
userCanSellToFund: number,
userCanBuyFromFund: number,
}[] = await tokenSwap.getLiquidityInfo(fundPubkey: PublicKey);
If you have any questions, feel free to reach out on Discord or Twitter​
Copy link