Skip to content

orca-so/whirlpools

Repository files navigation

Whirlpools

Whirlpools is an open-source concentrated liquidity AMM contract on the Solana blockchain. This repository contains the Rust smart contract and SDKs to interact with a deployed program.

The official deployment of the whirlpool contract can be found at the whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc address on:

The contract is deployed using verifiable build, so that you can ensure that the hash of the on-chain program matches the hash of the program in this codebase.

The program has been audited several times by different security firms.

Usage

This repository contains several libraries that can be used to interact with the Whirlpools contract. For most purposes you can use our high-level SDKs, @orca-so/whirlpools for Typescript projects, and orca_whirlpools for Rust projects.

For specific use-cases you can opt for integrating with lower level packages such as:

  • @orca-so/whirlpools-client & orca_whirlpools_client - auto-generated client for the Whirlpools program that contains account, instruction and error parsing.
  • @orca-so/whirlpools-core & orca_whirlpools_core - utility, math and quoting functions used by other packages.

The legacy Typescript SDK (@orca-so/whirlpools-sdk) remains a solid choice, and it’s currently the only option if your project uses Solana Web3.js.

For a more detailed overview of our SDK suite and usage examples, visit our developer documentation site.

Local Development

This monorepo contains all the code needed to build, deploy and interact with the Whirlpools contract.

Requirements

  • Anchor v0.29.0
  • Solana v1.17.22

Getting Started

Automated Setup Script

For a complete development environment setup, use the provided setup script:

chmod +x scripts/setup.sh
./scripts/setup.sh

This script installs all required dependencies and builds the project. It's designed for fresh environments (cloud VMs, containers, new machines) and doesn't check for existing versions. The script also serves as a reference for understanding which dependencies are needed at each stage.

Manual Setup

If you prefer manual installation or already have some dependencies:

  • Install system dependencies (build tools, Node.js, Rust, Solana CLI, Anchor)
    • Reference scripts/setup.sh for the exact versions and installation steps
  • Clone this repository: git clone https://github.com/orca-so/whirlpools
  • Install JavaScript dependencies: yarn
  • Build the project: yarn build
  • Set up a Solana wallet if needed (see below)

Setting up a Solana wallet

  • Create a new keypair using solana-keygen new.
  • Check if you have a valid wallet address using solana address.
  • Set your local config to the Solana devnet env using solana config set --url https://api.devnet.solana.com.
  • Give yourself some devnet SOL (for transaction fees) using solana airdrop 1.
  • Check if you have a positive balance using solana balance.

Components

This repository uses NX to manage the Rust and Typescript codebases. This allows us to have a monorepo with multiple packages and share code between them. Dependencies between packages are automatically resolved by NX, so you don't have to worry about managing that yourself.

This repository is split up into several parts. The following is a (non-exhaustive) list of the components and their purpose.

  • /programs/* - Rust programs that are deployed on Solana.
  • /ts-sdk/* - Typescript SDKs for interacting with the programs.
  • /rust-sdk/* - Rust SDKs for interacting with the programs.
  • /docs/* - Documentation for the programs and SDKs.
  • /legacy-sdk/* - Legacy Typescript SDKs and integration tests.

Commands

All commands should be run from the root of the repository. NX will try to run a command with the same name for each individual component, skipping the component if that specific command does not exist.

Below is a (non-exhaustive) list of available commands:

  • yarn build - compile the components for deployment or serving.
  • yarn clean - clean up all local build products, useful for when builds are failing.
  • yarn test - run the tests for all components.
  • yarn format - run formatter to format code.

If you look closely, the commands just call individual commands specified in the component's package.json file. These commands should not be run by themselves as it will not resolve the right dependencies and will not execute the prerequisites. Instead you can specify which package to run with yarn build programs/whirlpool, yarn test legacy-sdk/whirlpool, etc.

If you want to stream the logs of a specific command you can add the --output-style stream flag to the command. This allows you to view the logs of the command as they are being produced which can be useful for longer running tasks like integration tests.

Changesets

When contributing to this repository, please include a changeset with your changes. You can create a changeset by running yarn changeset. If your changes are not related to any of the packages, you can create an empty changeset by running yarn changeset --empty. In your pull request, you do not have to manually update the version numbers.

To publish packages to npm and cargo, you can run run the publish gh action. This will update the versions of the packages and publish them to npm and cargo.

Support

Have problems integrating with the SDK? Pop by over to the Orca Discord #dev-questions channel and chat with one of our engineers.

Feedback

Got ideas on how to improve the system? Open up an issue on github and let's brainstorm more about it together!

About

Open source concentrated liquidity AMM contract on Solana

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 41

Languages