Account types
MarketAccount
The central account for a prediction market. Exists at themarket PDA.
| Field | Type | Description |
|---|---|---|
marketId | bigint | Auto-incrementing ID assigned at creation |
marketType | number | 0 = YesNo, 1 = MultiOutcome |
numOutcomes | number | Number of outcome options (2 for YesNo, 2-4 for multi) |
category | number | Market category enum (0-6) |
creator | PublicKey | Market creator |
resolver | PublicKey | Wallet authorized to post the outcome |
closeTime | bigint | Unix timestamp when betting closes |
state | number | Current state (0=Active, 1=Closed, 2=Resolved, 3=Unresolved, 4=PendingResolution) |
totalBetsCount | bigint | Total number of bets placed |
pool0 | bigint | Revealed pool for outcome 0 (set by MPC callback) |
pool1 | bigint | Revealed pool for outcome 1 |
pool2 | bigint | Revealed pool for outcome 2 (multi only) |
pool3 | bigint | Revealed pool for outcome 3 (multi only) |
outcomeValue | number | Winning outcome index (set after resolution) |
payoutRatio | bigint | Payout per unit stake × ODDS_SCALE (1e9) |
creatorBond | bigint | Locked bond amount in micro-USDC |
minBet | bigint | Market-specific minimum bet in micro-USDC |
challengePeriod | bigint | Seconds for the dispute window (v0.2+) |
disputed | boolean | Whether a flag was raised during challenge window (v0.2+) |
resolutionDeadline | bigint | Timestamp when refunds become claimable |
claimDeadline | bigint | Timestamp when claim period ends |
inlineQuestion | string | Question text for v1/v2 (legacy) market accounts |
bump | number | PDA bump seed |
For v0.2+ markets (
state === 4 ever touched), the question lives in a separate MarketQuestion PDA rather than inline. Use fetchMarketQuestions to hydrate questions in batch.EncryptedPositionAccount
Records an encrypted bet. Exists at theposition PDA keyed by (market, user, betIndex).
| Field | Type | Description |
|---|---|---|
user | PublicKey | Bettor’s wallet |
market | PublicKey | Market PDA |
encryptedAmount | Uint8Array | 32-byte ciphertext of the bet stake |
encryptedSide | Uint8Array | 32-byte ciphertext of the chosen outcome |
userPubkey | Uint8Array | Bettor’s x25519 public key (needed for decryption) |
nonce | bigint | u128 nonce used for encryption (convert to 16 LE bytes to decrypt) |
entryOdds | bigint | Locked-in odds × ODDS_SCALE at bet time |
netAmount | bigint | Plaintext net stake after fees (asserted by circuit) |
betIndex | bigint | Index of this bet for the (user, market) pair |
claimed | boolean | Whether payout or refund was claimed |
computationQueued | boolean | Whether the MPC computation was queued |
bump | number | PDA bump seed |
GlobalStateAccount
Singleton protocol config. There is only one per deployment.| Field | Type | Description |
|---|---|---|
marketCounter | bigint | Next market ID to assign |
protocolFeeRate | number | Protocol fee in basis points (e.g., 50 = 0.5%) |
lpFeeRate | number | LP (creator) fee in basis points (e.g., 150 = 1.5%) |
protocolTreasury | PublicKey | Wallet receiving protocol fees |
acceptedMint | PublicKey | USDC mint accepted by this deployment |
admin | PublicKey | Admin wallet for overrides |
bump | number | PDA bump seed |
LpPositionAccount
Tracks the creator’s bond and accumulated LP fees per market.| Field | Type | Description |
|---|---|---|
market | PublicKey | Market PDA |
creator | PublicKey | Creator wallet |
bond | bigint | Original bond deposited |
lpFees | bigint | Accumulated LP fees from all bets |
withdrawn | boolean | Whether funds have been withdrawn |
bump | number | PDA bump seed |
MarketQuestionAccount v0.2+
Stores the question text for v0.2+ markets (separate PDA to save space inMarketAccount).
| Field | Type | Description |
|---|---|---|
market | PublicKey | Associated market PDA |
question | string | Full question text (max 200 bytes) |
bump | number | PDA bump seed |
Fetchers
All fetchers are also available as methods on theCypherClient namespaces.
TypeScript
Display helpers
TypeScript
marketPhase
Returns a human-readable phase string based on the market’s state and timestamps. Use this to drive UI state.TypeScript
cancelEligibility
Pre-flight check before showing a cancel button.TypeScript
parseEmbeddedOptions
Extracts option labels from a[A|B|C] question suffix.
TypeScript
marketFormatVersion
Detects the market account layout version from byte length.TypeScript
MarketQuestion PDA.