Orca Typescript SDK
The Orca SDK contains a set of simple to use APIs to allow developers to integrate with the Orca exchange platform.
Learn more Orca here.
Trading Orca Liquidity Pools
- Get detailed quotes and make swaps between trading pairs in an Orca Pool
- Check your Orca Pool LP token balance and total supply
Supported Orca Pools
- SOLUSDC, SOLUSDT, RAYSOL, ETHSOL, ETHUSDC
Features Coming Soon
- Supporting more pools on Orca!
- More trader information (APY, Volume)
- Deposit/Withdraw from OrcaPools
Installation
Use your environment's package manager to install @orca-so/sdk and other related packages into your project.
yarn add @orca.so/sdk @solana/web3.js decimal.js
npm install @orca.so/sdk @solana/web3.js decimal.js
Usage
import { Connection, Keypair } from "@solana/web3.js";
import { getOrca, OrcaPoolConfig, OrcaU64 } from "@orca-so/sdk";
try {
const connection = new Connection(url, "singleGossip");
const orca = getOrca(connection);
const owner: Keypair = getKeyPair();
let pool = orca.getPool(OrcaPoolConfig.ETH_USDC);
let ethUsdcLPBalance = await pool.getLPBalance(owner.publicKey);
let ethUsdcLPSupply = await pool.getLPSupply();
let usdcToken = pool.getTokenB();
let tradeValue = new Decimal(1.1);
let quote = await pool.getQuote(usdcToken, tradeValue, new Decimal(0.1));
const txId = await pool.swap(owner, usdcToken, tradeValue, quote.getMinOutputAmount());
} catch (err) {
}
Technical Notes
Decimals & OrcaU64
The SDK relies on the use of Decimal for number inputs and Decimal/OrcaU64 for token-value inputs. If a Decimal instance is provided for a token-value input, it will be automatically transformed to the token's scale.
Funding Associated Token Addresses
The swap() function assumes the owner keypair address has already created & initialized the associated token addresses for the trading pair tokens. The swap will fail if this is not the case.
Support
Integration Questions
Have problems integrating with the SDK? Pop by over to our Discord #integrations channel and chat with one of our engineers.
Issues / Bugs
If you found a bug, open up an issue on github with the prefix [ISSUE]. To help us be more effective in resolving the problem, be specific in the steps it took to reproduce the problem (ex. when did the issue occur, code samples, debug logs etc).
Feedback
Got ideas on how to improve the system? Open up an issue on github with the prefix [FEEDBACK] and let's brainstorm more about it together!
License
MIT