Session Data Structure

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

Players

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.

Deposit Amount

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

Reward

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

• It is calculated using the formula:

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.
Total Tickets

• 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].

Start / Duration / End

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.

Winning Numbers

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.

IsFinalized

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

Last updated