Rust SDK#
The canonical Rust crate is seesaw-sdk. It exposes the same generated v1
instruction, PDA, account, and math contract as the other clients.
use seesaw_sdk::{
codecs::{decode_market, decode_deep_orderbook},
errors::SdkError,
pda::{derive_market_pda, derive_orderbook_pda},
};
use solana_pubkey::Pubkey;
pub fn read_market(
feed_id: &[u8; 32],
duration_seconds: u64,
market_id: u64,
creator: &Pubkey,
program_id: &Pubkey,
fetch_finalized_bytes: impl Fn(&Pubkey) -> Result<Vec<u8>, SdkError>,
) -> Result<(), SdkError> {
let (market_address, _) =
derive_market_pda(feed_id, duration_seconds, market_id, creator, program_id);
let (orderbook_address, _) = derive_orderbook_pda(&market_address, program_id);
let market = decode_market(&fetch_finalized_bytes(&market_address)?)?;
let orderbook = decode_deep_orderbook(&fetch_finalized_bytes(&orderbook_address)?)?;
println!("{market:?} {orderbook:?}");
Ok(())
}
This function uses an application fetch adapter; map RPC failures into your
error handling and reject missing accounts or unexpected owners before returning
bytes. Derivation returns (Pubkey, bump). The orderbook has its own PDA; it is
not a field on the decoded market. Import helpers through their public modules.
Use the pinned workspace toolchain and cargo test --locked. Account readers
validate the encoded layout; callers must check program ownership, derived
addresses and related-account identities. Deep orderbooks use only capacities 64, 128, 256, 512, 1024,
2048, and 4096.
For markets originated elsewhere, keep source provenance and proof epoch and submit through the Reclaim registered-resolver service. The Seesaw trade, redeem, and close instructions remain the same canonical v1 builders.
From a checkout:
cargo test --manifest-path packages/sdk-rust/Cargo.toml --locked
Cross-language instruction and account vectors are under
packages/test-vectors.