Python SDK#
The canonical Python package is seesaw-sdk. It shares instruction, PDA,
account-layout, and math vectors with the TypeScript and Rust clients.
from collections.abc import Callable
from solders.pubkey import Pubkey
from seesaw import (
derive_market_pda,
derive_orderbook_pda,
decode_market,
decode_deep_orderbook,
)
def read_market(
feed_id: bytes,
duration_seconds: int,
market_id: int,
creator: Pubkey,
fetch_finalized_bytes: Callable[[Pubkey], bytes],
):
market_address, _ = derive_market_pda(
feed_id, duration_seconds, market_id, creator
)
orderbook_address, _ = derive_orderbook_pda(market_address)
market = decode_market(fetch_finalized_bytes(market_address))
orderbook = decode_deep_orderbook(fetch_finalized_bytes(orderbook_address))
return market_address, market, orderbook
Supply a 32-byte feed ID and an application fetch_finalized_bytes adapter.
The adapter must fetch finalized account data, reject missing accounts and
unexpected owners, and return binary bytes. PDA helpers return (Pubkey, bump);
the orderbook address is derived separately, not read from a market field.
Use finalized account data for settlement and balances. Validate discriminator, size, version, PDA, and related-market fields before using a decoded value. Deep orderbooks accept only the canonical capacities 64, 128, 256, 512, 1024, 2048, and 4096.
For external markets, integrate the Reclaim service and preserve the external reference, proof epoch, and source provenance. The service resolves through the registered resolver; it is not a second Python SDK family.
From a checkout:
pip install -e packages/sdk-python
python -m pytest packages/sdk-python/tests
Run pnpm --filter @seesaw/test-vectors test to verify cross-language parity.