docs
Searchโ€ฆ
๐Ÿ›
Governance Contract
The Governance Contract contains logic for holding governance polls and handling VEGAS Token staking, and allows the Terra-vegas casino to be governed by its users in a decentralised manner.
It is a fork from the Governance Contract developed by the Anchor protocol.
After the initial bootstrapping of Terra-vegas contracts, the Gov Contract is assigned to be the owner of all contracts in Terra-vegas.New proposals for change are submitted as polls, and are voted on by VEGAS stakers through the voting procedure. Polls can contain messages that can be executed directly without changing the Terra-vegas code.The Gov Contract keeps a balance of VEGAS tokens, which it uses to reward stakers with funds it receives from the player bets and the reserve contract deposits on the anchor protocol.

Config

Key
Type
Description
owner
CanonicalAddr
Address of contract owner
token_contract
CanonicalAddr
Contract address of VEGAS Token (VEGAS)
quorum
Decimal
Minimum percentage of participation required for a poll to pass
threshold
Decimal
Minimum percentage of yes votes required for a poll to pass
voting_period
u64
Number of blocks during which votes can be cast [blocks]
timelock_period
u64
Number of blocks required after a poll pass before executing changes [blocks]
expiration_period
u64
Number of blocks after a poll's voting period during which the poll can be executed [blocks]
proposal_deposit
Uint128
Minimum VEGAS deposit required for submitting a new poll
snapshot_period
u64
Window of time (number of blocks) allowed for poll snapshot before a poll's end [blocks]

InstantiateMsg

1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InstantiateMsg {
3
pub quorum: Decimal,
4
pub threshold: Decimal,
5
pub voting_period: u64,
6
pub timelock_period: u64,
7
pub expiration_period: u64,
8
pub proposal_deposit: Uint128,
9
pub snapshot_period: u64,
10
}
Copied!
Key
Type
Description
quorum
Decimal
Minimum percentage of participation required for a poll to pass
threshold
Decimal
Minimum percentage of yes votes required for a poll to pass
voting_period
u64
Number of blocks during which votes can be cast [blocks]
timelock_period
u64
Number of blocks required after a poll pass before executing changes [blocks]
expiration_period
u64
Number of blocks after a poll's voting period during which the poll can be executed [blocks]
proposal_deposit
Uint128
Minimum VEGAS deposit required for submitting a new poll
snapshot_period
u64
Window of time (number of blocks) allowed for poll snapshot before a poll's end [blocks]

ExecuteMsg

Receive

Can be called during a CW20 token transfer when the Gov contract is the recipient. Allows the token transfer to execute a Receive Hook as a subsequent action within the same transaction.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
Receive {
5
sender: String,
6
amount: Uint128,
7
msg: Binary,
8
}
9
}
Copied!

โ€‹

Key
Type
Description
sender
String
Sender of token transfer
amount
Uint128
Amount of tokens received
msg
Binary
Base64-encoded JSON of Receive Hook

[Internal] ExecutePollMsgs

Executes messages in a passed poll. Can only by issued by Gov.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
ExecutePollMsgs {
5
poll_id: u64,
6
}
7
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

RegisterContracts

Registers the contract addresses (i.e. Terra-vegas Token, VEGAS) to Gov.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
RegisterContracts {
5
token_contract: String,
6
}
7
}
Copied!
โ€‹
Key
Type
Description
token_contract
String
Contract address of Terra-vegas Token (VEGAS)

UpdateConfig

Updates the configuration of the Gov contract.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
UpdateConfig {
5
owner: Option<String>,
6
quorum: Option<Decimal>,
7
threshold: Option<Decimal>,
8
voting_period: Option<u64>,
9
timelock_period: Option<u64>,
10
expiration_period: Option<u64>,
11
proposal_deposit: Option<Uint128>,
12
snapshot_period: Option<u64>,
13
}
14
}
Copied!
โ€‹
Key
Type
Description
owner
String
Address of contract owner
quorum
Decimal
New percentage of participation required for a poll to pass
threshold
Decimal
New percentage of yes votes required for a poll to pass
voting_period
u64
New number of blocks during which votes can be cast [blocks]
timelock_period
u64
New number of blocks required after a poll pass before executing changes [blocks]
expiration_period
u64
New number of blocks after a poll's voting period during which the poll can be executed [blocks]
proposal_deposit
Uint128
New minimum VEGAS deposit required for submitting a new poll
snapshot_period
u64
New window of time (number of blocks) allowed for poll snapshot before a poll's end [blocks]

CastVote

Submits a user's vote for an active poll. Once a user has voted, they cannot change their vote with subsequent messages (increasing voting power, changing vote option, cancelling vote, etc.)
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
CastVote {
5
poll_id: u64,
6
vote: VoteOption,
7
amount: Uint128,
8
}
9
}
10
โ€‹
11
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
12
#[serde(rename_all = "snake_case")]
13
pub enum VoteOption {
14
Yes,
15
No,
16
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID
vote
VoteOption
Can be yes or no
amount
Uint128
Amount of voting power (staked VEGAS) to allocate

WithdrawVotingTokens

Removes specified amount of staked VEGAS tokens from a staking position and returns them to a user's balance. Withdraws all staked VEGAS tokens if amount is not specified.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
WithdrawVotingTokens {
5
amount: Option<Uint128>,
6
}
7
}
Copied!
Key
Type
Description
amount*
Uint128
Amount of VEGAS tokens to withdraw
* = optional

EndPoll

Can be issued by anyone to end the voting for an active poll. Triggers tally the results to determine whether the poll has passed. The current block height must exceed the end height of voting phase.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
EndPoll {
5
poll_id: u64,
6
}
7
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

ExecutePoll

Can be issued by anyone to implement into action the contents of a passed poll. The current block height must exceed the end height of the poll's effective delay.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
ExecutePoll {
5
poll_id: u64,
6
}
7
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

SnapshotPoll

Snapshots the total amount of staked VEGAS and stores the number to the specified poll. This staked VEGAS amount is used to determine the degree of participation for this poll, calculated by dividing the total amount of VEGAS voted to the poll with the total staked VEGAS supply at the time of EndPoll. Can only be issued within a window of snapshot_period blocks before the poll's end_height.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum ExecuteMsg {
4
SnapshotPoll {
5
poll_id: u64,
6
}
7
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

Receive Hooks

StakeVotingTokens

WARNING Sending VEGAS tokens to the Gov contract without issuing this hook will lead to PERMANENT LOSS OF FUNDS and will be irrevocably donated to the reward pool for stakers.

CreatePoll

Issued when sending VEGAS tokens to the Gov contract to create a new poll. Will only succeed if the amount of tokens sent meets the configured proposal_deposit amount. Can contain a list of generic messages to be issued by the Gov contract if it passes (can invoke messages in other contracts it owns).
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum Cw20HookMsg {
4
CreatePoll {
5
title: String,
6
description: String,
7
link: Option<String>,
8
execute_msgs: Option<Vec<PollExecuteMsg>>,
9
}
10
}
11
โ€‹
12
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13
#[serde(rename_all = "snake_case")]
14
pub struct PollExecuteMsg {
15
pub order: u64,
16
pub contract: String,
17
pub msg: Binary,
18
}QueryMsg
Copied!

โ€‹

Key
Type
Description
title
String
Poll title
description
String
Poll description
link*
String
URL to external post about poll (forum, PDF, etc.)
execute_msgs*
Vec<PollExecuteMsg>
List of governance messages to be issued by Gov contract upon poll execution
โ€‹
โ€‹
โ€‹
order
u64
Order sequence of message
contract
String
Contract address of governance message recipient
msg
Binary
New minimum VEGAS deposit required for submitting a new poll
snapshot_period
u64
Base64-encoded JSON of governance message
* = optional

QueryMsg

Config

Gets the configuration for the Gov contract.
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub token_contract: String,
5
pub quorum: Decimal,
6
pub threshold: Decimal,
7
pub voting_period: u64,
8
pub timelock_period: u64,
9
pub expiration_period: u64,
10
pub proposal_deposit: Uint128,
11
pub snapshot_period: u64,
12
}
Copied!

ConfigResponse

Rust
1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: String,
4
pub token_contract: String,
5
pub quorum: Decimal,
6
pub threshold: Decimal,
7
pub voting_period: u64,
8
pub timelock_period: u64,
9
pub expiration_period: u64,
10
pub proposal_deposit: Uint128,
11
pub snapshot_period: u64,
12
}
Copied!

State

Gets state information for the Gov contract.
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
State {}
5
}
Copied!

StateResponse

1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2
pub struct StateResponse {
3
pub poll_count: u64,
4
pub total_share: Uint128,
5
pub total_deposit: Uint128,
6
}
Copied!

Staker

Gets information for the specified VEGAS staker.
Rust
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Staker {
5
address: String,
6
}
7
}
Copied!

StakerResponse

1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct StakerResponse {
3
pub balance: Uint128,
4
pub share: Uint128,
5
pub locked_balance: Vec<(u64, VoterInfo)>, // (Voted Poll's ID, VoterInfo)
6
}
7
โ€‹
8
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
9
pub struct VoterInfo {
10
pub vote: VoteOption,
11
pub balance: Uint128,
12
}
13
โ€‹
14
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
15
#[serde(rename_all = "snake_case")]
16
pub enum VoteOption {
17
Yes,
18
No,
19
}Poll
Copied!

Poll

Gets information for the specified poll.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Poll {
5
poll_id: u64,
6
}
7
}
Copied!
1
{
2
"poll": {
3
"poll_id": 8
4
}
5
}
Copied!
โ€‹

PollResponse

Rust
JSON
1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct PollResponse {
3
pub id: u64,
4
pub creator: String,
5
pub status: PollStatus,
6
pub end_height: u64,
7
pub title: String,
8
pub description: String,
9
pub link: Option<String>,
10
pub deposit_amount: Uint128,
11
pub execute_data: Option<PollExecuteMsg>,
12
pub yes_votes: Uint128, // balance
13
pub no_votes: Uint128, // balance
14
pub staked_amount: Option<Uint128>,
15
pub total_balance_at_end_poll: Option<Uint128>,
16
}
17
โ€‹
18
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
19
#[serde(rename_all = "snake_case")]
20
pub enum PollStatus {
21
InProgress,
22
Passed,
23
Rejected,
24
Executed,
25
Expired, // Deprecated
26
Failed,
27
}
28
โ€‹
29
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
30
#[serde(rename_all = "snake_case")]
31
pub struct ExecuteMsg {
32
pub order: u64,
33
pub contract: String,
34
pub msg: Binary,
35
}
Copied!
1
{
2
"id": 8,
3
"creator": "terra1...",
4
"status": "executed",
5
"end_height": 123456,
6
"title": "...",
7
"description": "...",
8
"link": "https://...",
9
"deposit_amount": "100000000",
10
"execute_data": [
11
{
12
"order": 1,
13
"contract": "terra1...",
14
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmluYXJ5IiB9"
15
},
16
{
17
"order": 2,
18
"contract": "terra1...",
19
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmluYXJ5IiB9"
20
}
21
],
22
"yes_votes": "100000000",
23
"no_votes": "100000000",
24
"staked_amount": "100000000",
25
"total_balance_at_end_poll": "100000000"
26
}
Copied!

Polls

Gets information for all polls.
Rust
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Polls {
5
filter: Option<PollStatus>,
6
start_after: Option<u64>,
7
limit: Option<u32>,
8
order_by: Option<OrderBy>,
9
}
10
}
11
โ€‹
12
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13
#[serde(rename_all = "snake_case")]
14
pub enum PollStatus {
15
InProgress,
16
Passed,
17
Rejected,
18
Executed,
19
Expired, // Deprecated
20
Failed,
21
}
22
โ€‹
23
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
24
#[serde(rename_all = "snake_case")]
25
pub enum OrderBy {
26
Asc,
27
Desc,
28
}
Copied!
โ€‹

PollsResponse

Rust
1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct PollsResponse {
3
pub polls: Vec<PollResponse>,
4
}
5
โ€‹
6
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
7
pub struct PollResponse {
8
pub id: u64,
9
pub creator: String,
10
pub status: PollStatus,
11
pub end_height: u64,
12
pub title: String,
13
pub description: String,
14
pub link: Option<String>,
15
pub deposit_amount: Uint128,
16
pub execute_data: Option<PollExecuteMsg>,
17
pub yes_votes: Uint128, // balance
18
pub no_votes: Uint128, // balance
19
pub staked_amount: Option<Uint128>,
20
pub total_balance_at_end_poll: Option<Uint128>,
21
}
22
โ€‹
23
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
24
#[serde(rename_all = "snake_case")]
25
pub enum PollStatus {
26
InProgress,
27
Passed,
28
Rejected,
29
Executed,
30
Expired, // Deprecated
31
Failed,
32
}
33
โ€‹
34
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
35
#[serde(rename_all = "snake_case")]
36
pub struct PollExecuteMsg {
37
pub order: u32,
38
pub contract: String,
39
pub msg: Binary,
40
}
Copied!

Voters

Gets voter information of the poll with the specified ID.
Rust
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Voters {
5
poll_id: u64,
6
start_after: Option<String>,
7
limit: Option<u32>,
8
order_by: Option<OrderBy>,
9
}
10
}
Copied!

VotersResponse

Rust
1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct VotersResponse {
3
pub voters: Vec<VotersResponseItem>,
4
}
5
โ€‹
6
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
7
pub struct VotersResponseItem {
8
pub voter: String,
9
pub vote: VoteOption,
10
pub balance: Uint128,
11
}
12
โ€‹
13
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
14
#[serde(rename_all = "snake_case")]
15
pub enum VoteOption {
16
Yes,
17
No,
18
}
Copied!
โ€‹