docs
Searchโฆ
๐ฒ
Dice game logic
Note: During this game, players bet against the casino and not against other players.
Classic dice game is based on a randomly generated integer from 2 to 12 which represents the outcome of throwing a pair of six-sided dice.
Players can make bets on rolling two dice over or equal to a certain value. The table below shows the winning payout values for all possible outcomes based on the 1% casino advantage (P * W = 0.99).
Outcome
=12
>=11
>=10
>=9
>=8
>=7
>=6
>=5
>=4
>=3
>=2
Probability
1/36
3/36
6/36
10/36
15/36
21/36
26/36
30/36
33/36
35/36
36/36
Winning payout(coefficient, W)
35,64
11,88
5,94
3,564
2,376
1,697
1,37
1,188
1,08
1,0182
N/A
In the game app UI, the user selects an outcome on which they want to bet, sees their odds and their payout coefficient and sets the amount of UST they would like to wager.
The outcome on which the user bets is recorded in the message of the transaction with the bet amount sent to the smart contract when the user places their bet.
The player can only make a limited number of bets per game round, which is set as a parameter in the smart contract initially by the admin and later by the DAO. By default, it is limited to 1 bet per address per round.
The game process is carried out in rounds, with fixed duration set for each game separately as a parameter. Round duration parameter will be set initially by the admin and later by the DAO, with default value being 5 minutes. During these 5 minutes the players can place their bets and wait for the end of the round.
Every 5 minutes a new random number is obtained from the oracle contract and the game contract settles all bets collected up to that moment. After the round is complete, the player should manually check the results (also publicly verifiable on the oracle) and claim their winnings.
Maximum Betting amount
There is a maximum amount that players can bet per round. This amount depends on how much money currently exist on the casino reserve. Every round this limit is recalculated based on the new reserve amount. Currently it is possible to bet up to 1/50 of the casinos reserve. and this parameter can be changed by the DAO votes. The current 1/50 was chosen after the terra-vegas team wrote and ran simulations that aim to maximise the growth speed of the casino while keeping the risk of bankruptcy low. The code and results of these simulations are open on our Github.
End of the round
At then end of the round, the dice game contract checks with terrand the outcome number of the dice.
Based on that it calculates the rewards of all players who have placed their bets within that round. and checks against its own UST balance. If it doesn't have enough coins to pay back the players it will withdraw the needed funds from the reserve which in turn withdraws the funds from Anchor protocol. Player can then check and claim their rewards.
Whenever the dice-game contract reaches and passes a specific amount of funds (initialised at 10K \$UST and later on voted by the DAO) it will send all its funds minus a minimum cashflow to the reserve contract that will in turn deposit it into Anchor Protocol.