> ## 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.

# Position Model

> Complete reference for the Position data structure.

A Position represents a user's share holdings in a specific market.

***

## Schema

```typescript theme={"dark"}
interface Position {
  market: string;         // Market address
  user: string;           // User's wallet address
  outcomeAmounts: number[]; // Shares held per outcome
}
```

***

## Field Details

**market** `string`

The on-chain address of the market this position belongs to.

**user** `string`

The wallet address of the position holder.

**outcomeAmounts** `number[]`

Array of share counts, indexed by outcome. For a binary market (Yes/No), index 0 is "Yes" and index 1 is "No".

***

## Example

Binary market position:

```json theme={"dark"}
{
  "market": "ABC123def456...",
  "user": "MyWallet789...",
  "outcomeAmounts": [1500, 0]
}
```

Multi-outcome position:

```json theme={"dark"}
{
  "market": "XYZ789abc...",
  "user": "MyWallet789...",
  "outcomeAmounts": [500, 300, 200, 0]
}
```

***

## Position Value

Calculate the current value by multiplying shares by prices:

```typescript theme={"dark"}
function getPositionValue(
  outcomeAmounts: number[],
  prices: number[]
): number {
  return outcomeAmounts.reduce((total, shares, i) => {
    return total + (shares * prices[i]);
  }, 0);
}
```

***

## Account Creation

Positions are created automatically on first trade in a market:

* PDA derived from `["position", market, user]`
* Requires rent (\~0.002 SOL)
* Persists until closed

***

## Fetching Positions

> [tab] SDK
>
> ```typescript theme={"dark"}
> // Single position
> const position = await sdk.orica.fetchPosition(marketAddress, userPubkey);
>
> // All user positions
> const positions = await sdk.orica.fetchUserPositions(userPubkey);
> ```

> [tab] API
>
> Positions are included in user trade history via WebSocket:
>
> ```typescript theme={"dark"}
> const ws = new WebSocket("wss://api.orica.markets/ws/activity");
> ws.send(JSON.stringify({ type: "user", address: userAddress }));
> ```


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