A Solana program for staking ORCA tokens with liquid staking functionality. Users can stake ORCA tokens to receive xORCA tokens proportional to their share of the pool, and later unstake with a cooldown period.
The easiest way to get started with xORCA is using Docker:
# Start development environment
docker compose --profile dev up
# Run tests
docker compose --profile test up
# Build all components (generates code, builds SDK, etc.)
yarn build:dockerFor more detailed Docker instructions, see DOCKER.md.
solana-program/- The main Solana program implementation- Implements staking, unstaking, and withdrawal functionality
- Uses Pinocchio primitives for account assertions and PDA derivation
- Emits Borsh-serialized events for all operations
rust-client/- Rust client library for interacting with the programsrc/generated/- Auto-generated client code from IDLsrc/math/- Math utility functions (compiled to WASM)src/pda/- Program Derived Address utilities
js-client/- JavaScript/TypeScript client librarysrc/generated/- Auto-generated client code from IDLsrc/generated/wasm/- Generated WASM bindings and TypeScript wrappers- Universal compatibility for browser and Node.js environments
solana-program-test/- Comprehensive test suite for the Solana program- Integration tests using LiteSVM
- Tests for all instructions and edge cases
ts-scripts/- TypeScript scripts for program interaction- Scripts for staking, unstaking, withdrawing, and program management
- Status checking and pending withdrawal monitoring
codama.js- Code generation script using Codama framework
For local development, you'll need to install the following tools:
- Rust (latest stable) - Install Rust
- Node.js (LTS) - Install Node.js
- Yarn - Install Yarn
- Solana CLI tools - Install Solana CLI
- shank-cli - Install with
cargo install shank-cli
For Docker-based builds, you only need:
- Docker - Install Docker
-
Install dependencies:
yarn install cargo build
-
Build everything (contract, generate code, build SDKs):
yarn build
This will:
- Build the Solana program and generate IDL using shank
- Generate TypeScript and Rust client code using Codama
- Build the TypeScript SDK
- Build the Rust SDK with WASM features
- Format code with Prettier and cargo fmt
-
Or build individual components:
# Build contract and generate IDL yarn build:contract # Generate client code from IDL using Codama yarn generate # Build TypeScript SDK only yarn build:ts # Build Rust SDK only (with WASM features) yarn build:rs
-
Run tests:
cargo test yarn workspace @orca-so/xorca test
The project uses Codama for generating type-safe client code from the Solana program IDL. The generation process:
- Builds the Solana program and generates IDL using shank
- Uses Codama to generate TypeScript and Rust client code
- Includes account discriminators and padding fields
- Generates WASM bindings for Rust math functions
The generated code is placed in:
js-client/src/generated/- TypeScript client coderust-client/src/generated/- Rust client code
yarn build- Build everything locally (contract, generate code, build SDKs, format)yarn build:docker- Build everything using Docker (no local dependencies needed)yarn build:contract- Build the Solana program and generate IDLyarn build:test- Build the Solana program with test features and generate IDLyarn build:ts- Build the TypeScript SDK onlyyarn build:rs- Build the Rust SDK with WASM featuresyarn generate- Generate client code from the Solana program IDL using Codamayarn clean- Clean generated artifacts (generated code, IDL, WASM packages)yarn fmt- Format code with Prettier and cargo fmtyarn test- Run all tests (TypeScript and Rust)yarn test:contract- Build with test features, generate code, and run tests
The project uses Yarn workspaces for managing multiple packages:
js-client- The main JavaScript/TypeScript client library (@orca-so/xorca)ts-scripts- TypeScript scripts for program interaction
- Docker Setup - Complete Docker setup guide
- API Documentation - JavaScript client documentation
See LICENSE for details.