How igneous-labs/sanctum-router-sdk works
Project type and purpose
• This is a blockchain SDK repository for Solana, consisting of:
• An on-chain core program (Rust) that implements a “router” for staking operations across multiple protocols (Lido, Marinade, SPL Stake Pool, Reserve).
• An off-chain client SDK (TypeScript) for composing and submitting transactions to that on-chain program.
• A suite of integration tests and JSON fixtures to exercise the router against a local Solana validator.
File-structure analysis
• Top level:
• core/ – Rust library (Cargo.toml, src/…) containing the on-chain program logic: instructions, quote generators, PDA derivation, router modules for each protocol, trait definitions.
• ts/sdk/ – TypeScript SDK to interface with the on-chain program: PDA helpers, instruction builders, router interfaces, build scripts.
• ts/tests/ – Integration tests and scripts that spin up a local validator (via docker-compose-local-validator.yml), load JSON fixtures, and validate end-to-end behavior.
• test-fixtures/ – Sample Solana account data for each router and token mint to seed the local validator.
• Configuration: .gitignore, pre-commit, Docker compose for local validator, etc.
Key README insights
• Minimal README; core purpose described by directory names (“router‐sdk”) and successor to a previous similar SDK.
• Individual subdirectories contain their own READMEs with test instructions.
a. On-chain core program (Rust)
– Modules: instructions/*, routers/*, quote/*, pda.rs, traits/*
– Exposed program ID on Solana cluster
– Externally invokes (CPI) other Solana programs: Lido, Marinade, SPL Stake Pool, Reserve
b. Off-chain client SDK (TypeScript)
– PDA derivation, instruction construction, RPC client calls
– Postbuild and packaging scripts
c. Test harness
– Local Solana validator (Docker) loaded with JSON fixtures
– TypeScript tests driving the SDK against the program
d. External protocols on Solana
– Lido program, Marinade program, SPL Stake Pool program, Reserve program
e. Data flows
– Client → JSON RPC → On-chain program → CPI → External protocol → On-chain program → Client (via transaction confirmation)
Architectural patterns and principles
• Router pattern: single entrypoint dispatching to protocol-specific handlers
• PDA (Program Derived Address) abstraction: deterministic account addresses for program state
• Trait‐based design in Rust for uniform instruction/quote interfaces
• SDK/Program separation: clear boundary between on-chain logic and off-chain clients
• Use of JSON fixtures for reproducible local testing