Skip to main content

Account Layouts

Detailed specification of all on-chain accounts in the Seesaw protocol.

Account Overview

ConfigAccount

Protocol-wide configuration. Singleton per program.

Layout

OffsetFieldTypeSizeDescription
0discriminator[u8; 8]8Account type identifier
8authorityPubkey32Protocol admin
40treasuryPubkey32Fee recipient
72default_settlement_mintPubkey32Default USDC mint
104taker_fee_bpsu162Taker fee (default: 30)
106maker_rebate_bpsu162Maker rebate (default: 10)
108crank_reward_lamportsu648SOL per crank op
116tick_size_bpsu162Price tick (default: 100)
118max_orders_per_useru162Order limit per user
120max_order_sizeu648Max shares per order
128markets_createdu648Total markets created
136total_volumeu12816Total trading volume
152total_fees_collectedu12816Total fees collected
168versionu81Config version
169bumpu81PDA bump seed
170_reserved[u8; 86]86Future use
Total256

Derivation

let (config_pda, bump) = Pubkey::find_program_address(
    &[b"seesaw", b"config"],
    &program_id,
);

MarketAccount

Individual market state for a single epoch (configurable duration: 60s–7 days).

Layout

OffsetFieldTypeSizeDescription
0discriminator[u8; 8]8Account type identifier
8market_idu648Epoch ID = floor(timestamp/900)
16pyth_feedPubkey32Oracle price feed
48settlement_mintPubkey32USDC mint
80t_starti648Epoch start time
88t_endi648Epoch end time
96created_ati648Creation timestamp
104resolved_ati648Resolution timestamp (0 if pending)
112start_pricei648Opening price (0 if not captured)
120start_price_confu648Start price confidence
128start_price_expoi324Start price exponent
132start_price_timestampi648Start snapshot time
140end_pricei648Closing price (0 if not captured)
148end_price_confu648End price confidence
156end_price_expoi324End price exponent
160end_price_timestampi648End snapshot time
168outcomeu810=None, 1=Up, 2=Down
169total_yes_sharesu648Total YES in circulation
177total_no_sharesu648Total NO in circulation
185total_collateralu648Vault balance
193total_positionsu324Position count
197settled_positionsu324Settled count
201total_volumeu648Trading volume
209total_tradesu324Trade count
213max_confidence_ratio_bpsu162Confidence gating (0=disabled)
215bumpu81Market PDA bump
216orderbook_bumpu81Orderbook PDA bump
217vault_bumpu81Vault PDA bump
218_reserved[u8; 294]294Future use
Total512

Derivation

let (market_pda, bump) = Pubkey::find_program_address(
    &[b"seesaw", b"market", &market_id.to_le_bytes()],
    &program_id,
);

State Encoding

outcomeState
0Not resolved
1UP (end >= start)
2DOWN (end < start)

OrderbookAccount

Order book for a market with bids and asks.

Layout

OffsetFieldTypeSizeDescription
0discriminator[u8; 8]8Account type identifier
8marketPubkey32Parent market
40bid_countu162Active bids
42ask_countu162Active asks
44next_order_idu648Next order ID
52best_bid_priceu162Best bid (0 if empty)
54best_ask_priceu162Best ask (10000 if empty)
56bumpu81PDA bump
57_header_reserved[u8; 7]7Reserved
64bids[Order; 63]5040Bid orders
5104asks[Order; 63]5040Ask orders
10144_padding[u8; 96]96Alignment padding
Total10,240

Order Structure (80 bytes)

OffsetFieldTypeSizeDescription
0order_idu648Unique ID
8ownerPubkey32Order owner
40price_bpsu162Canonical price
42quantityu648Remaining quantity
50original_quantityu648Original size
58timestampi648Placement time
66original_sideu81User's original side
67is_activebool1Active flag
68_reserved[u8; 12]12Reserved

Side Encoding

ValueOriginal SideCanonical Side
0BuyYesBid
1SellYesAsk
2BuyNoAsk (converted)
3SellNoBid (converted)

Derivation

let (orderbook_pda, bump) = Pubkey::find_program_address(
    &[b"seesaw", b"orderbook", market_pda.as_ref()],
    &program_id,
);

VaultAccount

SPL Token account holding market collateral.

Layout

Standard SPL Token account (165 bytes):

OffsetFieldTypeSizeDescription
0mintPubkey32Token mint
32ownerPubkey32Owner (market PDA)
64amountu648Token balance
72delegateOption<Pubkey>36Delegate
108stateAccountState1Account state
109is_nativeOption<u64>12Native flag
121delegated_amountu648Delegated
129close_authorityOption<Pubkey>36Close auth
Total165

Derivation

let (vault_pda, bump) = Pubkey::find_program_address(
    &[b"seesaw", b"vault", market_pda.as_ref()],
    &program_id,
);

UserPositionAccount

User's position in a specific market.

Layout

OffsetFieldTypeSizeDescription
0discriminator[u8; 8]8Account type identifier
8marketPubkey32Parent market
40ownerPubkey32Position owner
72yes_sharesu648YES shares owned
80no_sharesu648NO shares owned
88locked_yes_sharesu648Locked in sell orders
96locked_no_sharesu648Locked in sell orders
104collateral_depositedu648Total deposited
112collateral_lockedu648Locked in buy orders
120settledbool1Settlement flag
121payoutu648Settlement payout
129total_boughtu648Shares bought
137total_soldu648Shares sold
145total_fees_paidu648Taker fees
153total_rebates_earnedu648Maker rebates
161order_countu162Active orders
163first_trade_ati648First trade time
171last_trade_ati648Last trade time
179bumpu81PDA bump
180_reserved[u8; 76]76Future use
Total256

Derivation

let (position_pda, bump) = Pubkey::find_program_address(
    &[
        b"seesaw",
        b"position",
        market_pda.as_ref(),
        user_pubkey.as_ref(),
    ],
    &program_id,
);

Discriminators

Each account type has a unique 8-byte discriminator:

fn discriminator(name: &str) -> [u8; 8] {
    let hash = sha256(format!("account:{}", name));
    hash[..8]
}
AccountDiscriminator Input
ConfigAccountaccount:ConfigAccount
MarketAccountaccount:MarketAccount
OrderbookAccountaccount:OrderbookAccount
UserPositionAccountaccount:UserPositionAccount

Rent Requirements

AccountSizeRent-Exempt (~)
ConfigAccount256 bytes0.00189 SOL
MarketAccount512 bytes0.00356 SOL
OrderbookAccount10,304 bytes0.07164 SOL
VaultAccount165 bytes0.00203 SOL
UserPositionAccount256 bytes0.00189 SOL

Account Relationships

Next Steps