Session Lifecycle

A typical game session progresses through several stages:

  1. Starting a Session:

    • A new session begins at a specified block timestamp, initiating the countdown based on the set duration.

  2. Depositing:

    • Users can deposit their assets into the session, earning tickets calculated as: User ticket(weight) = deposit amount * remaining time until pool finish

    • The earlier a user deposits, the better their chances of winning due to the time-weighted ticket calculation.

    • User Participation Storage Cost:

      • When making a deposit for the first time in a session, users must cover a small storage cost, typically around 0.0025 NEAR.

      • This fee is used to store user data for the session and prevents potential abuse like “Million Small Deposits” attacks.

      • If a user decides to cash out before the session ends, the storage cost is refunded.

  3. Boosting Chances:

    • Users can add more deposits during the session to boost their chances of winning, with the ticket calculation remaining the same.

  4. Cashing Out:

    • Users can withdraw their deposited assets at any time before the session ends. Cashing out removes the user from the session and updates the total tickets and amount accordingly.

  5. Finalizing a Session:

    • At the end of the session, anyone can call the finalize_session function to determine the winner(s) based on the generated random number.

    • The reward is calculated, and the session data is updated to reflect the final state.

  6. Claiming Rewards:

    • The selected winner(s) can claim their rewards, while all other participants can reclaim their initial deposits. The isClaimed flag ensures that users cannot claim more than once.

By structuring the game sessions with clear rules and transparent data, FunStake ensures a fair and engaging experience for all participants. This approach not only builds trust but also enhances the overall user experience.

Last updated