Whirpools 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 whilrpool 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.
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 versions below v2.
For a more detailed overview of our SDK suite and usage examples, visit our developer documentation site.
This monorepo contains all the code needed to build, deploy and interact with the Whirlpools contract.
These instructions are for setting up a development environment on a Mac. If you are using a different operating system, you will need to adjust the instructions accordingly.
brew install node gcc@12
.export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
.curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
.curl -sSfL https://release.solana.com/v1.17.22/install | sh
.export PATH="/Users/$(whoami)/.local/share/solana/install/active_release/bin:$PATH"
.cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
.avm install 0.29.0 && avm use 0.29.0
.git clone https://github.com/orca-so/whirlpools
.yarn
.yarn build
.solana-keygen new
.solana address
.solana config set --url https://api.devnet.solana.com
.solana airdrop 1
.solana balance
.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 sevaral 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.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.
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.
Have problems integrating with the SDK? Pop by over to the Orca Discord #dev-questions channel and chat with one of our engineers.
Got ideas on how to improve the system? Open up an issue on github and let's brainstorm more about it together!