> For the complete documentation index, see [llms.txt](https://docs.funstake.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.funstake.io/how-funstake-works/game-sessions/session-data-structure.md).

# Session Data Structure

Each game session contains crucial data fields to ensure transparency and proper functioning:

<details>

<summary>Players</summary>

A mapping of accountId to player details, which includes:

* **Tickets:** The number of tickets the user has earned through deposits.
  * The chance of winning is shown as \
    `(User Tickets / Total Tickets of Game Session) * 100`.
* **Amount:** The total deposit amount by the user.
  * This is used to return the correct deposit amount on cashout or claim actions.
* **isClaimed:** A boolean indicating whether the user has claimed their deposit and rewards at the end of the session.

</details>

<details>

<summary>Deposit Amount</summary>

• This represents the cumulative deposits of all participants in the session. It is updated whenever a user makes a deposit or cashes out.

• The amount is crucial for calculating the exact rewards at the end of the session.

</details>

<details>

<summary>Reward</summary>

• This is the final reward amount distributed to the winner(s) at the end of the session.

• It is calculated using the formula:

{% code overflow="wrap" %}

```
Reward = (Total Staked Balance + Generated Rewards) - Total Deposit Amount

- Total Staked Balance is the total amount in the staking contract, including any yield generated.
- Total Deposits is the sum of all participants' deposits in the game session.
```

{% endcode %}

</details>

<details>

<summary>Total Tickets</summary>

• The cumulative number of tickets issued in the session. It is updated with each deposit and cashout action.

• Total tickets are used to randomly choose a winning number in the range **\[0-Total Tickets]**.

</details>

<details>

<summary>Start / Duration / End</summary>

**Start:**\
• The block timestamp when the game session starts.\
\
**Duration:**\
• The length of time the game session will last.\
• It is used to calculate the end time and restrict certain operations like deposits or cashouts after the session ends.\
\
**End:**\
• Calculated as **Start + Duration**. It marks the official end of the game session.

</details>

<details>

<summary>Winning Numbers</summary>

**Count of Winning Numbers:**\
• The number of winners to be selected. Currently, FunStake supports one winner, but this can be adjusted in the future to allow multiple winners.

**Winning Numbers:**\
• The winning number(s) for the session, determined when the session is finalized.

</details>

<details>

<summary>IsFinalized</summary>

• A boolean indicating whether the session has ended and been finalized. Once finalized, certain actions like depositing or cashing out are disabled for that session.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.funstake.io/how-funstake-works/game-sessions/session-data-structure.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
