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,
currency_record: &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,
currency_record,
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. The market PDA is currency-scoped: currency_record is the registered currency record of the settlement mint (currency::derive_currency_record_pda). 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 source markets, use seesaw_sdk::source_result. The builders accept
the original signed result bytes and derive the source control and witness
registry accounts from the deployment ID. Use build_lifecycle_result
for resolution, halt, or a close-time update. The program verifies the
witness signatures and lifecycle revision when the instruction lands.
The source result example builds an unsigned resolution instruction from a synthetic fixture.
From a checkout:
cargo test --manifest-path packages/sdk-rust/Cargo.toml --locked
Cross-language instruction and account vectors are under
packages/test-vectors.