Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@orca-so/whirlpool-sdk
Advanced tools
Note: This is a pre-release SDK for the Orca Whirlpool Program and is deprecated. Please use the new Whirlpool SDK. If you are migrating to the new Whirlpool SDK, Read this document
The Orca Whirlpool SDK contains a set of simple to use APIs to allow developers to interact with the Orca concentrated liquidity pools. This package will be sunsetted soon.
Learn more Orca here.
Supported Orca Pools
ORCA/USDC
, SOL/USDC
and mSOL/USDC
.Coming Soon
@orca-so/whirlpool-client-sdk
so power-users can construct Whirlpool instruction calls directly. (Feel free to take a look when you pull down this module!)Use your environment's package manager to install @orca-so/whirlpool-sdk and other related packages into your project.
yarn add @orca-so/whirlpool-sdk
npm install @orca-so/whirlpool-sdk
import { Provider } from "@project-serum/anchor";
import { Connection, PublicKey } from "@solana/web3.js";
import { OrcaWhirlpoolClient } from "@orca-so/whirlpool-sdk";
// NOTE: The following code will work currently but the API will change in upcoming releases.
// You can use Anchor.Provider.env() and use env vars or pass in a custom Wallet implementation to do signing
const provider = new Provider(connection, wallet, Provider.defaultOptions());
// Derive the Whirlpool address from token mints
const orca = new OrcaWhirlpoolClient({ network: OrcaNetwork.MAINNET });
const poolAddress = await orca.pool.derivePDA(ORCA_MINT, USDC_MINT, false)
.publicKey;
// Fetch an instance of the pool
const poolData = await orca.getPool(poolAddress);
if (!poolData) {
return;
}
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),
refresh: true,
tickLowerIndex: priceToTickIndex(new Decimal(0), 6, 6),
tickUpperIndex: priceToTickIndex(new Decimal(100), 6, 6),
});
const openPositionTx = await orca.pool.getOpenPositionTx({
provider,
quote: openPositionQuote,
});
const openPositionTxId = await openPositionTx.tx.buildAndExecute();
// Construct a swap instruction on this pool and execute.
const swapQuote = await orca.pool.getSwapQuote({
poolAddress,
tokenMint: ORCA_MINT,
tokenAmount: new u64(1_000_000),
isInput: true,
refresh: true,
});
const swapTx = await orca.pool.getSwapTx({
provider,
quote: swapQuote,
});
const swapTxId = swapTx.buildAndExecute();
If you are using Provider.env(), you can invoke with the following:
ANCHOR_PROVIDER_URL=https://api.mainnet-beta.solana.com ANCHOR_WALLET=<Path to your keypair> ts-node <Path to file>.ts
Code is not stable
This repo is in a pre-release state. The public API will undergo a major refactor prior to our beta release.
Integration Questions
You are welcome to source-dive into the SDK and the inner @orca-so/whirlpool-client-sdk
to interact with the Whirlpool contract. However,we will not be able to provide integration support at this moment.
Issues / Bugs
If you found a bug, please message the team over at @integrations on Discord.
FAQs
Whirlpool SDK for the Orca protocol.
We found that @orca-so/whirlpool-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.