Development repository for generating TypeScript and Rust clients for Jupiter Perpetuals Protocol from IDL using Codama.
π¦ Looking to use the clients?
- TypeScript/JavaScript: npm package or see jup-perps-client-js/README.md
- Rust: Add
jup-perps-client-rustas dependency in your Cargo.toml
- Bun runtime (recommended)
- Node.js β₯ 24.0.0 (alternative)
- Git
Note: This repository does not include generated files. You must run the generator to create the client.
git clone https://github.com/monakki/jup-perps-client.git
cd jup-perps-client
bun install# Build specific clients
bun run build:js # Build TypeScript client
bun run build:rust # Build Rust client
# Test clients
bun run example:js # Test TypeScript client
bun run example:rust # Test Rust client- Multi-Language Support: Generates both TypeScript and Rust clients from single IDL
- IDL Processing: Converts Jupiter Perpetuals IDL using Codama framework
- Program Address Injection: Automatically sets correct program address
- Type Generation: Full type definitions for all accounts and instructions in both languages
- Documentation: JSDoc for TypeScript, Rustdoc for Rust
- RPC Integration: Built-in Solana RPC client support (works out of the box)
- Environment Variables: Configurable RPC URLs via environment variables
- Parallel Generation: Fast multi-language builds
# TypeScript Client
jup-perps-client-js/
βββ src/
β βββ accounts/ # Account fetchers (fetchPool, fetchCustody, etc.)
β βββ instructions/ # Instruction builders
β βββ types/ # TypeScript type definitions
β βββ programs/ # Program constants and utilities
β βββ index.ts # Main exports
βββ dist/ # Compiled JavaScript + TypeScript definitions
βββ examples/ # Usage examples
# Rust Client
jup-perps-client-rust/
βββ src/
β βββ accounts/ # Account fetchers (fetch_pool, fetch_custody, etc.)
β βββ instructions/ # Instruction builders
β βββ types/ # Rust type definitions
β βββ programs/ # Program constants
β βββ lib.rs # Main library
βββ examples/ # Usage examples
βββ Cargo.toml # Rust package configuration
jupiter-perps-client/
βββ generator/
β βββ idl/
β β βββ jupiter-perpetuals.json # Source IDL file
β βββ js/
β β βββ generate.ts # TypeScript generator
β β βββ add-jsdoc.ts # JSDoc enhancement
β βββ rust/
β β βββ generate.ts # Rust generator
β β βββ add-rust-docs.ts # Rustdoc enhancement
β β βββ fix-imports.ts # Solana compatibility fixes
β βββ generate-all.ts # Multi-language generator
βββ jup-perps-client-js/ # Generated TypeScript client
β βββ src/ # Generated TypeScript source
β βββ dist/ # Compiled JavaScript + definitions
β βββ examples/ # Usage examples
β βββ package.json # NPM package
βββ jup-perps-client-rust/ # Generated Rust client
β βββ src/ # Generated Rust source
β βββ examples/ # Usage examples
β βββ Cargo.toml # Cargo package
βββ package.json # Development scripts
βββ README.md # This file
# Generate clients from IDL
bun run generate # Generate both clients
bun run generate:js # Generate TypeScript client only
bun run generate:rust # Generate Rust client only
# Compile generated code
bun run compile:js # Compile TypeScript + add JSDoc
bun run compile:rust # Compile Rust (cargo build)
# Full build (generate + compile)
bun run build:js # Generate + compile TypeScript
bun run build:rust # Generate + compile Rust
# Test clients
bun run example:js # Test TypeScript client
bun run example:rust # Test Rust client
# Code quality
bun run format # Format TypeScript code
bun run lint # Lint TypeScript code
bun run check # Format + lint TypeScript
# Publishing
bun run publish:js # Publish TypeScript to npm
bun run publish:rust # Publish Rust to crates.io- IDL Processing: Codama converts Jupiter Perpetuals IDL to both TypeScript and Rust
- Program Address Injection:
updateProgramsVisitorsets correct program address for both languages - Language-Specific Processing:
- TypeScript: JSDoc enhancement, TypeScript compilation
- Rust: Import fixing, deprecated trait removal, Rustdoc enhancement
- Documentation: Both clients get comprehensive documentation (JSDoc/Rustdoc)
- RPC Integration: Both clients include fetch functionality with environment variable support
When Jupiter releases a new IDL version:
# 1. Replace the IDL file
cp new-jupiter-perpetuals.json generator/idl/jupiter-perpetuals.json
# 2. Regenerate both clients
bun run generate
# 3. Test the changes
bun run example:js
bun run example:rust
# 4. Update versions and publish
bun run publish:js # Update and publish TypeScript
bun run publish:rust # Update and publish RustTo modify the generation process:
For TypeScript client:
- Edit
generator/js/generate.tsfor core generation logic - Edit
generator/js/add-jsdoc.tsfor documentation improvements
For Rust client:
- Edit
generator/rust/generate.tsfor core generation logic - Edit
generator/rust/add-rust-docs.tsfor documentation - Edit
generator/rust/fix-imports.tsfor Solana compatibility
Testing changes:
bun run generate # Regenerate both clients
bun run example:js # Test TypeScript
bun run example:rust # Test RustDevelopment:
- Node.js β₯ 24.0.0
- Bun (recommended) or npm β₯ 10.0.0
- TypeScript for development
Rust Development (optional):
- Rust β₯ 1.75.0
- Cargo
MIT
These clients are auto-generated from Jupiter Perpetuals IDL files using Codama.
To make changes:
- Update IDL files in
generator/idl/folder - Rebuild packages with
bun run generate - Test both clients with
bun run example:jsandbun run example:rust
- These clients are designed for reading data from Jupiter Perpetuals
- For creating transactions, use the appropriate instructions from
instructions/ - Always verify account addresses are current and valid
- Use reliable RPC endpoints for production applications
- TypeScript: Supports both JavaScript and TypeScript projects
- Rust: RPC features enabled by default (
fetchfeature) - Environment Variables: Both clients support
SOLANA_RPC_URLconfiguration
If this client helps you build amazing Solana applications, consider supporting the project:
Solana: uJHFSYDcCRH2c6VLXY1kWBqGFmBb7JbF7FN8bsGAFtx
Your support helps maintain and improve this package for the community!