🎲Dice Game Contract

The Dice Game Contract contains the logic of the double dice game with the betting and distribution of the rewards to the players, the interaction with the reserve contract to handle the funds, and checking up the randomness from the terrand smart contract. This contract also handles the taxes on player wins and the casino advantage.

This contract is managed by the governance contract. Many of its execute messages are only allowed to be called from the governance contract

KeyTypeDescription

gov_contract_address

CanonicalAddr

Address of the gov contract to be able to change parameters through voting

reserve_address

CanonicalAddr

Address of the terra-vegas reserve contract

terrand_address

CanonicalAddr

Address of the terrand contract to pull the randomness from

max_cashflow

Decimal

maximum amount of UST to keep in the contract above which we send to the reserve contract

max_number_of_bets

Decimal

Maximum number of bets per player per round

win_tax

Decimal

tax to be applied on the players rewards after the round bets are settled

native_denom

String

the native coin to use for the bets

round_duration

vec

duration of the round in seconds

InstantiateMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub native_denom: String,
    pub advantage_value: String,
    pub win_tax: String,
    pub max_number_of_bets: u64,
    pub max_betting_ratio: u64,
    pub round_duration: u64,
    pub max_cashflow: Uint128,
    pub terrand_address: String,
    pub reserve_address: String,
    pub gov_contract_address: String,
}
KeyTypeDescription

gov_contract_address

CanonicalAddr

Address of the gov contract to be able to change parameters through voting

reserve_address

CanonicalAddr

Address of the terra-vegas reserve contract

terrand_address

CanonicalAddr

Address of the terrand contract to pull the randomness from

max_cashflow

Decimal

maximum amount of UST to keep in the contract above which we send to the reserve contract

max_number_of_bets

Decimal

Maximum number of bets per player per round

win_tax

Decimal

tax to be applied on the players rewards after the round bets are settled

native_denom

String

the native coin to use for the bets

round_duration

vec

duration of the round in seconds

ExecuteMsg

ChangeAdvantageValue

Changes the advantage ratio of the casino against the player

ChangeMaxCashflow

chenages the maximum amount of UST to keep in the contract above which we send to the reserve contract

Bet

To be called by a player to bet on a Live round. or to start a new round if some conditions are met.

ReceiveRewards

To be called by a player to claim their accumulated rewards from the previous round(s) if they have any

DrainGame

Sends all the contract balance to the reserve contract

StopGame

Halts the game so no player can bet anymore

QueryMsg

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    WinConfficients {},
    PlayerRewards {
        addr: String,
    },
    CurrentRound {},
    Bets {
        addr: String,
        round: u64,
    },
    OutcomeHistory {},
    GetConfig {},
    GetBettingLimit{},

WinConfficients

Returns the winning multiplier per dice roll bet. it is a vector that depends on the distribution of probability of the double dice and the casino advantage.

PlayerRewards

Returns the wins of the player who calls this function.

CurrentRound

Returns the current dice game round.

OutcomeHistory

Returns the outcome history of the dice. based on what terrand has generated.

Bets

Returns all the bets of a specific wallet for a specific dice round.

GetConfig

returns the dice game contract config

GetBettingLimit

Returns the maximum betting amount per round. This value is calculated every round based on how much money the reserve holds. This parameter is there to prevent players from betting higher than what the casino holds. The ratio is calculated based on some simulations the terra-vegas team has conducted.

Last updated