> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orica.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Accounts

> Understanding Orica's on-chain account structure.

Orica uses Program Derived Addresses (PDAs) to store all protocol state. Understanding these accounts helps you navigate the on-chain data.

***

## Account Types

### Orica Program

| Account | Description | Seeds |
| - | - | - |
| GlobalState | Protocol configuration | `["global_state"]` |
| FeeVault | Protocol fee collection | `["fee_vault"]` |
| Market | Individual market state | `["market", globalState, marketId]` |
| MarketVault | Market's USDC holdings | `["market_vault", globalState, marketId]` |
| VaultAuthority | Signer for vault transfers | `["vault_authority", globalState, marketId]` |
| Position | User's shares in a market | `["position", market, user]` |

### Disputes Program

| Account | Description | Seeds |
| - | - | - |
| DisputeConfig | Dispute system configuration | `["dispute_config"]` |
| Dispute | Dispute state for a market | `["dispute", market]` |
| DisputeVote | User's vote in a dispute | `["dispute_vote", dispute, user]` |
| DisputeMessage | On-chain message | `["message", dispute, author, index]` |
| BoostRecord | Message boost tracking | `["boost_record", message, booster]` |

***

## GlobalState

The root configuration account for the protocol.

```typescript theme={"dark"}
interface GlobalState {
  authority: PublicKey;           // Protocol admin
  admins: PublicKey[];            // Authorized admins
  creationFee: BN;                // Market creation fee
  authorityTradingFeeBps: number; // Protocol trading fee
  creatorTradingFeeBps: number;   // Creator trading fee
  redemptionFeeBps: number;       // Redemption fee
  usdcMint: PublicKey;            // USDC token mint
  feeVault: PublicKey;            // Fee collection vault
  marketCount: BN;                // Total markets created
}
```

***

## Market Account

Each market is a separate account containing:

```typescript theme={"dark"}
interface Market {
  id: BN;                    // Unique numeric ID
  creator: PublicKey;        // Creator's wallet
  question: string;          // The question (max 200 chars)
  metadataUri: string;       // IPFS URI for extended metadata
  closeTime: BN;             // Trading end time
  createdAt: BN;             // Creation timestamp
  status: MarketStatus;      // Current status
  outcomeCount: number;      // Number of outcomes
  pools: BN[];               // USDC in each outcome pool
  supplies: BN[];            // Shares minted per outcome
  optionNames: string[];     // Short outcome names
  resolution: Resolution;    // Resolution data (if resolved)
  creatorFeeVault: PublicKey; // Where creator fees go
}
```

***

## Position Account

Tracks a user's holdings in a specific market:

```typescript theme={"dark"}
interface Position {
  market: PublicKey;        // Which market
  user: PublicKey;          // Whose position
  outcomeAmounts: BN[];     // Shares per outcome
  bump: number;             // PDA bump seed
}
```

> [!NOTE]
>
> Position accounts are created on first trade and persist until explicitly closed.

***

## Deriving PDAs

Use the SDK helpers to derive account addresses:

```typescript theme={"dark"}
// Orica PDAs
const [globalState] = sdk.orica.pda.globalState();
const [market] = sdk.orica.pda.market(globalState, marketId);
const [position] = sdk.orica.pda.position(market, userPubkey);

// Disputes PDAs
const [dispute] = sdk.disputes.pda.dispute(market);
const [vote] = sdk.disputes.pda.disputeVote(dispute, userPubkey);
```

***

## Account Rent

All accounts require rent (SOL deposit) for storage:

| Account | Approximate Size | Rent |
| - | - | - |
| GlobalState | \~500 bytes | \~0.004 SOL |
| Market | \~1KB | \~0.008 SOL |
| Position | \~200 bytes | \~0.002 SOL |
| Dispute | \~300 bytes | \~0.003 SOL |
| DisputeMessage | \~500 bytes | \~0.004 SOL |

> [!NOTE]
>
> Rent is paid by the transaction signer. It's refundable if the account is closed.

***

## Fetching Accounts

> [tab] SDK
>
> ```typescript theme={"dark"}
> // Fetch and decode automatically
> const globalState = await sdk.orica.fetchGlobalState();
> const market = await sdk.orica.fetchMarket(marketAddress);
> const position = await sdk.orica.fetchPosition(marketAddress, userPubkey);
> ```

> [tab] Raw RPC
>
> ```typescript theme={"dark"}
> // Fetch raw account data
> const accountInfo = await connection.getAccountInfo(address);
>
> // Decode manually using Anchor
> const decoded = program.coder.accounts.decode("Market", accountInfo.data);
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.