Skip to main content

Orca Whirlpools Core SDK

This package provides developers with advanced functionalities for interacting with the Whirlpool Program on Solana. Originally written in Rust, it has been compiled to WebAssembly (Wasm). This compilation makes the SDK accessible in JavaScript/TypeScript environments, offering developers the same core features and calculations for their Typescript projects. The SDK exposes convenient methods for math calculations, quotes, and other utilities, enabling seamless integration within web-based projects.

Key Features

  • Math Library: Contains a variety of functions for math operations related to bundles, positions, prices, ticks, and tokens, including calculations such as determining position status or price conversions.
  • Quote Library: Provides utility functions for generating quotes, such as increasing liquidity, collecting fees or rewards, and swapping, to help developers make informed decisions regarding liquidity management.

Installation:

Usage

Here are some basic examples of how to use the package:

Math Example

The following example demonstrates how to use the isPositionInRange function to determine whether a position is currently in range.
Expected output:

Quote Example

The following example demonstrates how to use the increaseLiquidityQuoteA function to calculate a quote for increasing liquidity given a token A amount.
Expected output:

Important Util helpers

Reference the following utility types to help you interact with the Whirlpool protocol.

PDAUtil

Utility class to help you derive the PDA for Whirlpool accounts

🔗 PDAUtil | @orca-so/whirlpools

PriceMath

Utility methods to help you convert between sqrt-price, price and tick index.

🔗 PriceMath | @orca-so/whirlpools

TickUtil

Utility class hosting Tick utility methods such as finding initializable ticks, deriving tick array start-index etc.

🔗 TickUtil | @orca-so/whirlpools

TickArrayUtil

Utility class to help fetch TickArray data.

🔗 TickArrayUtil | @orca-so/whirlpools

PoolUtil

A collection of utility methods that you may use when interacting with the Whirlpool account.

🔗 PoolUtil | @orca-so/whirlpools