+
Skip to content

orca-so/xorca

Repository files navigation

xORCA Staking Program

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.

Quick Start with Docker

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:docker

For more detailed Docker instructions, see DOCKER.md.

Project Structure

  • 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 program
    • src/generated/ - Auto-generated client code from IDL
    • src/math/ - Math utility functions (compiled to WASM)
    • src/pda/ - Program Derived Address utilities
  • js-client/ - JavaScript/TypeScript client library
    • src/generated/ - Auto-generated client code from IDL
    • src/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

Development

Prerequisites

For local development, you'll need to install the following tools:

For Docker-based builds, you only need:

Local Development

  1. Install dependencies:

    yarn install
    cargo build
  2. 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
  3. 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
  4. Run tests:

    cargo test
    yarn workspace @orca-so/xorca test

Code Generation

The project uses Codama for generating type-safe client code from the Solana program IDL. The generation process:

  1. Builds the Solana program and generates IDL using shank
  2. Uses Codama to generate TypeScript and Rust client code
  3. Includes account discriminators and padding fields
  4. Generates WASM bindings for Rust math functions

The generated code is placed in:

  • js-client/src/generated/ - TypeScript client code
  • rust-client/src/generated/ - Rust client code

Available Scripts

  • 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 IDL
  • yarn build:test - Build the Solana program with test features and generate IDL
  • yarn build:ts - Build the TypeScript SDK only
  • yarn build:rs - Build the Rust SDK with WASM features
  • yarn generate - Generate client code from the Solana program IDL using Codama
  • yarn clean - Clean generated artifacts (generated code, IDL, WASM packages)
  • yarn fmt - Format code with Prettier and cargo fmt
  • yarn test - Run all tests (TypeScript and Rust)
  • yarn test:contract - Build with test features, generate code, and run tests

Workspaces

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

Documentation

License

See LICENSE for details.

About

The xORCA Solana program and clients

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载