> For the complete documentation index, see [llms.txt](https://terra-vegas.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://terra-vegas.gitbook.io/docs/contracts/reserve-contract.md).

# Reserve Contract

The Reserve Contract contains logic for holding the funds of the casino. Initially, the funds are received from the ICO and later on increased (or decreased) by the games managed by the reserve. The reserve fund decreases by: Deficient games: Games that don’t have enough funds to pay back the winners withdraw from the reserve to payback the winners Daily stakers dividends The reserve fund increases by: Winning games: Game contracts that get their balance above a certain threshold will send the extra funds to the reserve ICO Anchor deposit yield.

{% hint style="info" %}
This contract is managed by the governance contract.\
Many of its execute messages are only allowed to be called from the governance contract
{% endhint %}

| Key                     | Type          | Description                                                                |
| ----------------------- | ------------- | -------------------------------------------------------------------------- |
| `anchor_market_address` | CanonicalAddr | Address of anchor market contract                                          |
| `gov_contract_address`  | CanonicalAddr | Address of the gov contract to be able to change parameters through voting |
| `anchor_token_address`  | CanonicalAddr | Address of anchor token ANC contract                                       |
| `threshold`             | Decimal       | maximum amount of UST above which we deposit to Anchor                     |
| `games`                 | vec           | <p>Whitelisted games that are allowed to send and receive funds<br></p>    |

## InstantiateMsg <a href="#instantiatemsg" id="instantiatemsg"></a>

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub anchor_market_address: String,
    pub gov_contract_address: String,
    pub anchor_token_address: String,
    pub threshold: Uint128,
    pub native_denom: String,
}
```

| Key                     | Type          | Description                                                                |
| ----------------------- | ------------- | -------------------------------------------------------------------------- |
| `anchor_market_address` | CanonicalAddr | Address of anchor market contract                                          |
| `gov_contract_address`  | CanonicalAddr | Address of the gov contract to be able to change parameters through voting |
| `anchor_token_address`  | CanonicalAddr | Address of anchor token ANC contract                                       |
| `threshold`             | Decimal       | maximum amount of UST above which we deposit to Anchor                     |
| `games`                 | vec           | <p>Whitelisted games that are allowed to send and receive funds<br></p>    |

## ExecuteMsg

### ChangeThreshold <a href="#receive" id="receive"></a>

Changes the UST amount above which we deposit to Anchor

### AddGame <a href="#receive" id="receive"></a>

Whitelists a game contract. That game would be able to request funds from the reserve contract

### RemoveGame <a href="#receive" id="receive"></a>

Delists a game contract. That game would not be able to request funds from the reserve anymore

### RequestFunds <a href="#receive" id="receive"></a>

A game contracts execute this to request funds from the reserve contract

### DepositFunds <a href="#receive" id="receive"></a>

A game contracts execute this to deposit funds to the reserve contract

## QueryMsg

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    CurrentBalance {},
    GetThreshold {},
    ListGames {},
    BalanceHistory {},
}
```

### CurrentBalance <a href="#receive" id="receive"></a>

The current balance in the reserve contract. The calculation takes into account the uusd and the aUST with the current aUST price

### GetThreshold <a href="#receive" id="receive"></a>

Returns the current maximum amount of UST above which we deposit to Anchor

### ListGames <a href="#receive" id="receive"></a>

Lists all whitelisted games that are allowed to request funds from the reserve contract
