Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@orca-so/sdk

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/sdk

Typescript SDK for the Orca protocol.

  • 1.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7K
decreased by-38.29%
Maintainers
3
Weekly downloads
 
Created
Source

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

  • The SDK supports all pools currently listed on Orca

Provide Liquidity to Orca Pools

  • 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

Features Coming Soon

  • More trader information (APY, Volume)

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();

  // Get an instance of the ETH-USDC orca pool
  let pool = orca.getPool(OrcaPoolConfig.ETH_USDC);

  // Get the number of ETH-USDC LP tokens in your wallet
  let ethUsdcLPBalance = await pool.getLPBalance(owner.publicKey);

  // Get the total supply of ETH-USDC LP tokens
  let ethUsdcLPSupply = await pool.getLPSupply();

  // Get a quote of exchanging 1.1 ETH to USDC with a slippage tolerance of 0.1%
  // From the quote, you can get the current rate, fees, expected output amount and minimum output amount
  let ethToken = pool.getTokenA();
  let tradeValue = new Decimal(1.1);
  let quote = await pool.getQuote(ethToken, tradeValue, new Decimal(0.1));

  // Perform a swap for 1USDC to the quoted minimum amount of ETH
  // If the user does not have the Associated Token Address(ATA) to receive the output token, the ATA
  // instructions will be appended in the transaction.
  const txId = await pool.swap(owner, usdcToken, tradeValue, quote.getMinOutputAmount()).execute();
} catch (err) {
  // Handle errors
}

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.

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.

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

Keywords

FAQs

Package last updated on 27 Sep 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc