Nezha
  • 🏠Introduction to Nezha
  • How nezha works
    • Stake to Win
    • Nezha Epochs
    • Yield Farmer
  • Tickets
    • Stake per Ticket
    • Tickets
    • Bonus Tickets
    • Ticket Generation
  • The Draw
    • The Draw
    • Winning Sequence
    • No Draw Scenario
  • Prizes
    • Prize Tiers
    • Prizes
  • Fees
    • Staking
    • Unstaking
    • Claiming Prizes
  • Risks & Mitigations
    • Smart Contracts
    • Low Yield Returns
    • Negative Yield Returns
    • Tickets Outside Solana
    • Insurance Costs
  • Architecture
    • Overview
    • Game Contract
      • Epoch States
      • Token Accounts
      • State Accounts
      • Initialisation Instructions
      • State Transition Instructions
      • Other Instructions
      • Roles & Capabilities
      • Derived Account Roles
    • Draw Contract
      • State Accounts
      • Instructions
      • Roles & Capabilities
      • Derived Accounts
Powered by GitBook
On this page
  • Epoch(epoch_index)
  • LatestEpoch
  • Stake(owner)
  • StakeUpdateRequest(owner)
  • EpochWinnersMeta(epoch_index):
  • EpochWinnersPage(epoch_index, page):
  • StakingTicket(owner, epoch)
  1. Architecture
  2. Game Contract

State Accounts

Accounts that hold Nezha state

Notation: Foo(x, y) means an account whose PDA is derived using x and y. There will be different accounts for different values of x and y.

Epoch(epoch_index)

  • Information about an epoch.

  • Invested amount, return amount, how is the return split, etc.

LatestEpoch

  • Holds the index of the current epoch.

  • Use this index to derive the PDA of the current Epoch account.

  • Also holds the cumulative return rate of investments. cumulative_return_rate = epoch_1_return_rate * epoch_2_return_rate * ...

Stake(owner)

  • Holds information about a user's stake including starting_rate and amount

StakeUpdateRequest(owner)

  • We don't allow direct staking/unstaking into the contract, so that we can implement an AML flow later.

  • Instead, the user first creates a StakeUpdateRequest { amount } If amount > 0 (ie, type == Deposit): amount is moved from user's USDC ATA into PendingDepositVault

  • The admin then issues ApproveStakeUpdate instruction, indicating AML check is completed.

  • If the current epoch is in Running state, a background process on behalf of the admin will issue CompleteStakeUpdate instruction.

  • If amount > 0 (ie, type == Deposit): amount is moved from PendingDepositVault into DepositVault, and user's Stake account will reflect the new balance.

  • If amount < 0 (ie, type == Withdrawal): amount = min(abs(amount), User's stake balance) amount is moved from DepositVault into user's USDC ATA, and user's Stake account will reflect the new balance.

EpochWinnersMeta(epoch_index):

  • epoch

  • tier1, tier2, tier3:

    • total prize amount for this tier

    • claimable: true/false Used to mark the tier1 prize (jackpot) as unclaimable till we get it funded from the insurance provider.

  • status: track progress of uploading multiple pages of winners list

EpochWinnersPage(epoch_index, page):

  • winners: Vec<Winner>

    • winner wallet address

    • tier

    • prize

    • claimed = true/false (to prevent double claiming)

StakingTicket(owner, epoch)

  • We upload the tickets of each user as they are generated into arweave and store the URI in this account, to prevent any tampering.

PreviousToken AccountsNextInitialisation Instructions

Last updated 1 year ago