whirlpool-sdk 0.0.25
Install from the command line:
Learn more about npm packages
$ npm install @orca-so/whirlpool-sdk@0.0.25
Install via package.json:
"@orca-so/whirlpool-sdk": "0.0.25"
About this version
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.
- 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
- The SDK supports all pools currently listed on Orca
- Deposit liquidity to supported Orca Pools
- Deposit a trading pair, and receive LP token
- Withdraw liquidity from supported Orca Pools
- Withdraw a trading pair in exchange for LP token
Aquafarm Support
- After depositing liquidtiy to a pool, the LP token can be deposited into the corresponding farm to receive an equivalent amount of farm token
- Remember to withdraw the LP token in exchange for farm token before withdrawing liquidity from Orca Pool
DoubleDip Support
- For farms with double-dip, the aquafarm tokens can be deposited into double-dip farm to receive double-dip rewards
Features Coming Soon
- More trader information (APY, Volume)
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
// Get pool address from token mints
const orca = new OrcaWhirlpoolClient({ network: OrcaNetwork.MAINNET });
const poolAddress = await orca.pool.deriveAddress(ORCA_MINT, USDC_MINT);
// Get pool data
const poolData = await orca.getPool(poolAddress);
console.log(poolData.liquidity);
console.log(poolData.price);
console.log(poolData.tokenVaultAmountA);
console.log(poolData.tokenVaultAmountB);
// Open a position
const openPositionQuote = await orca.pool.getOpenPositionQuote({
poolAddress,
tokenMint: ORCA_MINT,
tokenAmount: new u64(1_000_000_000),
});
const openPositionTx = await orca.pool.getOpenPositionTx({
provider,
quote: openPositionQuote,
});
const openPositionTxId = await openPositionTx.buildAndExecute();
console.log("opened new position", openPositionTxId);
// Swap
const swapQuote = await orca.pool.getSwapQuote({
poolAddress,
tokenMint: ORCA_MINT,
tokenAmount: new u64(1_000_000),
});
const swapTx = await orca.pool.getSwapTx({
provider,
quote: swapQuote,
});
console.log("swapped", swapTx);
// Some additional functions:
// orca.admin.getInitRewardTx
// orca.admin.getSetRewardEmissionsTx
// orca.pool.getLiquidityDistribution
// orca.position.getAddLiquidityTx
// orca.position.getCollectFeesAndRewardsTx
// orca.position.getRemoveLiquidityTx
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.
Stability of the Public Util Functions
We hope you find the tools we used to build our API useful in the public/utils folder. Due to our on-going development of the Orca platform, we cannot guarrantee the stability of the util APIs. The trading APIs can only be upgraded on major version updates.
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!