orca
from sendaifun/skills
a public marketplace of all solana-related skills for agents to learn from!
37 stars6 forksUpdated Jan 22, 2026
npx skills add https://github.com/sendaifun/skills --skill orcaSKILL.md
Orca Whirlpools Development Guide
Orca is the most trusted DEX on Solana and Eclipse, built on a concentrated liquidity automated market maker (CLMM) called Whirlpools. This guide covers the Whirlpools SDK for building trading, liquidity provision, and pool management applications.
Overview
Orca Whirlpools provides:
- Token Swaps - Efficient token exchanges with low slippage and competitive rates
- Concentrated Liquidity - Provide liquidity within custom price ranges for higher capital efficiency
- Splash Pools - Simple full-range liquidity provision for beginners
- Position Management - Open, increase, decrease, and close liquidity positions
- Fee Harvesting - Collect trading fees and rewards from positions
- Pool Creation - Permissionless creation of new liquidity pools
Program IDs
| Network | Program ID |
|---|---|
| Solana Mainnet | whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc |
| Solana Devnet | whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc |
| Eclipse Mainnet | whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc |
| Eclipse Testnet | whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc |
Quick Start
Installation
New SDK (Solana Web3.js v2):
npm install @orca-so/whirlpools @solana/kit
Legacy SDK (Solana Web3.js v1):
npm install @orca-so/whirlpools-sdk @orca-so/common-sdk @coral-xyz/anchor@0.29.0 @solana/web3.js @solana/spl-token decimal.js
Core Utilities (optional):
npm install @orca-so/whirlpools-core @orca-so/whirlpools-client
Basic Setup (New SDK)
import {
setWhirlpoolsConfig,
setRpc,
setPayerFromBytes
} from "@orca-so/whirlpools";
import { createSolanaRpc, devnet } from "@solana/kit";
import fs from "fs";
// Configure for Solana Devnet
await setWhirlpoolsConfig("solanaDevnet");
await setRpc("https://api.devnet.solana.com");
// Load wallet from keypair file
const keyPairBytes = new Uint8Array(
JSON.parse(fs.readFileSync("./keypair.json", "utf8"))
);
const wallet = await setPayerFromBytes(keyPairBytes);
// Create RPC connection
const rpc = createSolanaRpc(devnet("https://api.devnet.solana.com"));
console.log("Wallet:", wallet.address);
Basic Setup (Legacy SDK)
import { WhirlpoolContext, buildWhirlpoolClient, ORCA_WHIRLPOOL_PROGRAM_ID } from "@orca-so/whirlpools-sdk";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import { Connection, Keypair } from "@solana/web3.js";
import fs from "fs";
// Setup connection
const connection = new Connection("https://api.mainnet-beta.solana.com", "confirmed");
// Load wallet
const secretKey = JSON.parse(fs.readFileSync("./keypair.json", "utf8"));
const wallet = new Wallet(Keypair.fromSecretKey(new Uint8Array(secretKey)));
// Create provider and context
const provider = new AnchorProvider(connection, wallet, {});
const ctx = WhirlpoolContext.from(connection, wallet, ORCA_WHIRLPOOL_PROGRAM_ID);
const client = buildWhirlpoolClient(ctx);
console.log("Wallet:", wallet.publicKey.toString());
Token Swaps
Swap with New SDK
import { swap, swapInstructions, setWhirlpoolsConfig } from "@orca-so/whirlpools";
import { address } from "@solana/kit";
await setWhirlpoolsConfig("solanaMainnet");
const poolAddress = address("POOL_ADDRESS_HERE");
const inputMint = address("INPUT_TOKEN_MINT");
const amount = 1_000_000n; // Amount in smallest units
const slippageTolerance = 100; // 100 bps = 1%
// Option 1: Use the simple swap function (builds and sends)
const txId = await swap(
rpc,
{ inputAmount: amount, mint: inputMint },
poolAddress,
slippageTolerance,
wallet
);
console.log("Swap transaction:", txId);
// Option 2: Get instructions for custom transaction building
const { instructions, quote } = await swapInstructions(
rpc,
{ inputAmount: amount, mint: inputMint },
poolAddress,
slippageTolerance,
wallet
);
console.log("Expected output:", quote.tokenEstOut);
console.log("Minimum output:", quote.tokenMinOut);
console.log("Price impact:", quote.priceImpact);
Exact Output Swap
// Swap to get exact output amount
const { instructions, quote } = await swapInstructions(
rpc,
{ outputAmount: 1_000_000n, mint: outputMint },
poolAddress,
slippageTolerance,
wallet
);
console.log("Max input required:", quote.tokenMaxIn);
Swap with Legacy SDK
import { WhirlpoolContext, swapQuoteByInputToken, buildWhirlpoolClient } from "@orca-so/whirlpools-sdk";
import { DecimalUtil, Percentage } from "@orca-so/common-sdk";
import Decimal from "decimal.js";
// Get the pool
const whirlpool = await client.getPool(poolAddress);
const whirlpoolData = whirlpool.getData();
// Get swap quote
const inputAmount = new Decimal("1.0"); // 1 token
const quote = await swapQuoteByInputToken(
whirlpool,
whirlpoolData.tokenMintA,
DecimalUtil.toBN(inputAmount, 9), // 9 decimals
Percentage.fromFraction(1, 100), // 1% slippage
ctx.program.
...
Repository
sendaifun/skillsParent repository
Repository Stats
Stars37
Forks6
LicenseApache License 2.0