Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,27 @@ This monorepo contains all the code needed to build, deploy and interact with th

### Getting Started

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.

* Install NodeJS and gcc-12 using `brew install node gcc@12`.
* Add gcc-12 headers to your cpath using `export CPATH="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"`.
* Install Rust lang using `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`.
* Install the Solana CLI using `curl -sSfL https://release.solana.com/v1.17.22/install | sh`.
* Add the Solana CLI to your path using `export PATH="/Users/$(whoami)/.local/share/solana/install/active_release/bin:$PATH"`.
* Install Anchor version manager using `cargo install --git https://github.com/coral-xyz/anchor avm --locked --force`.
* Install the latest Anchor version using `avm install 0.29.0 && avm use 0.29.0`.
* Clone this repository using `git clone https://github.com/orca-so/whirlpools`.
* Install the dependencies using `yarn`.
* Set up a Solana wallet if you don't have one already (see below).
* Run one of the commands below to get started such as `yarn build`.
#### Automated Setup Script

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

```bash
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

Expand Down
87 changes: 87 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
set -euo pipefail

# =============================================================================
# DEPENDENCY VERSIONS
# =============================================================================
NVM_VERSION="v0.40.3"
NODE_VERSION="22"
YARN_VERSION="4.6.0"
SOLANA_VERSION="v1.17.25"
ANCHOR_VERSION="v0.29.0"
RUST_VERSION_FOR_ANCHOR="1.76.0" # Required for building Anchor v0.29.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use 1.78.0 ?

yarn build should build everything. It uses 1.78.0 for contract build. (no need to switch default, we can use Rust 1.85.1 as default because package.json has the following setting)
https://github.com/orca-so/whirlpools/blob/main/programs/whirlpool/package.json#L5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Rust version in this line is specific to the installation of Anchor v0.29.0, and not the Whirlpools repo.

Background

I encountered an issue with using AVM to install v0.29.0.

Using Anchor's recommendation for installing Anchor:

cargo install --git https://github.com/coral-xyz/anchor avm --force
avm install 0.29.0

yields:

Error: Failed to install 0.29.0, is it a valid version?

So I decided to install Anchor v0.29.0 from source, but that would not compile with the latest version of Rust that comes with the default Rust installation, v1.90.0. Neither did it compile with v1.85.1. I tried multiple versions of Rust, and landed on v1.76 as a compatible version.

Testing your suggestions

That said, as a result of you review comment, I just tried v1.78 as well, and that works too. So, I believe we still need to switch the default right before building Anchor.

Furthermore, I tested the script without switching the default from v1.78.0 to v1.85.1 before trying yarn install and yarn build from the repo's root, and indeed the Whirlpool program builds, but building rust-tx-sender will fail with Error:

error: rustc 1.78.0 is not supported by the following packages:
        [email protected] requires rustc 1.81
        [email protected] requires rustc 1.80.0
        [email protected] requires rustc 1.80.0
        [email protected] requires rustc 1.80.0
        [email protected] requires rustc 1.81

I'm happy to switch to another version of Rust instead of 1.85.1, but I believe we still need to switch the default at least twice.

Copy link
Contributor Author

@calintje calintje Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow up
@wjthieme 's suggestion to use cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli instead of my code works without switching the Rust version. So the only thing left to do was to add rustup default ${RUST_VERSION_FOR_PROJECT} right before building the project, with the version being v1.84.0, which is the same version that's used by the GitHub workflows.

(The default v1.90.0 seems to not be compatible with WASM compilation)

RUST_VERSION_FOR_PROJECT="1.85.1" # Required for building Whirlpools project

# Resolve repo root from this script's directory
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
REPO_ROOT="$(cd -- "$SCRIPT_DIR/.." >/dev/null 2>&1 && pwd)"
echo "=== Repo root: $REPO_ROOT ==="

echo "=== Detecting system ==="
UNAME_OUT="$(uname -s)"
case "${UNAME_OUT}" in
Linux*) OS=Linux;;
Darwin*) OS=Mac;;
*) OS="UNKNOWN:${UNAME_OUT}"
esac
echo "Detected: $OS"

if [[ "$OS" == "Linux" ]]; then
echo "=== Updating system packages (Linux) ==="
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y build-essential pkg-config libssl-dev curl git
elif [[ "$OS" == "Mac" ]]; then
echo "=== Installing Xcode Command Line Tools ==="
xcode-select --install || true

echo "=== Installing Homebrew and dependencies ==="
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || eval "$(/usr/local/bin/brew shellenv)" 2>/dev/null || true
brew update
brew upgrade
brew install pkg-config openssl git
fi

echo "=== Installing NVM (Node Version Manager) ==="
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"

echo "=== Installing Node.js ${NODE_VERSION} and Yarn (via Corepack) ==="
nvm install ${NODE_VERSION}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally hate nvm 🦗. I always just do brew install node@18 or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script runs on both Linux and Mac. Would you recommend installing Brew for Linux as well?

I went with nvm because it's the first pick in Node's installation documentation. And maybe not super important, but Brew does not fall under Node's 'Recommended (Official)' installations., but under 'Community (Unofficial)' installations.

nvm use ${NODE_VERSION}
corepack enable
corepack prepare yarn@${YARN_VERSION} --activate

echo "=== Installing Rust via rustup ==="
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustc -V

echo "=== Installing Solana CLI ==="
sh -c "$(curl -sSfL https://release.anza.xyz/${SOLANA_VERSION}/install)"
source "$HOME/.profile" || true
solana -V

echo "=== Installing Anchor (${ANCHOR_VERSION}) ==="
rustup default ${RUST_VERSION_FOR_ANCHOR}
ANCHOR_TMP_DIR="$(mktemp -d)"
git clone https://github.com/coral-xyz/anchor "$ANCHOR_TMP_DIR/anchor"
cd "$ANCHOR_TMP_DIR/anchor"
git checkout ${ANCHOR_VERSION}
cd cli
cargo build --release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could do something like cargo install --git https://github.com/coral-xyz/anchor --tag v0.29.0 anchor-cli so you don't have to clone, build and link manually

mkdir -p "$HOME/.cargo/bin"
cp ../target/release/anchor "$HOME/.cargo/bin/anchor-${ANCHOR_VERSION}"
ln -sfn "$HOME/.cargo/bin/anchor-${ANCHOR_VERSION}" "$HOME/.cargo/bin/anchor"
export PATH="$HOME/.cargo/bin:$PATH"
cd "$REPO_ROOT"
rm -rf "$ANCHOR_TMP_DIR"

echo "=== Building local Whirlpools repo ==="
rustup default ${RUST_VERSION_FOR_PROJECT}
cd "$REPO_ROOT"
yarn install
yarn build

echo "=== Setup complete ==="