Search…
Gov
The Gov Contract contains logic for holding polls and Mirror Token (MIR) staking, and allows the Mirror Protocol to be governed by its users in a decentralized manner. After the initial bootstrapping of Mirror Protocol contracts, the Gov Contract is assigned to be the owner of itself and Mirror Factory.
New proposals for change are submitted as polls, and are voted on by MIR stakers through the voting procedure. Polls can contain messages that can be executed directly without changing the Mirror Protocol code.
The Gov Contract keeps a balance of MIR tokens, which it uses to reward stakers with funds it receives from trading fees sent by the Mirror Collector and user deposits from creating new governance polls. This balance is separate from the Community Pool, which is held by the Community contract (owned by the Gov contract).

Config

Key
Type
Description
mirror_token
HumanAddr
Contract address of Mirror Token (MIR)
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
proposal_deposit
Uint128
Minimum MIR deposit required for a new poll to be submitted
effective_delay
u64
Number of blocks after a poll passes to apply changes
voter_weight
Decimal
Ratio of protocol fee which will be distributed among the governance poll voters
snapshot_period
u64
Minimum number of blocks before the end of voting period which snapshot could be taken to lock the current quorum for a poll

InitMsg

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
pub struct InitMsg {
3
pub mirror_token: HumanAddr,
4
pub quorum: Decimal,
5
pub threshold: Decimal,
6
pub voting_period: u64,
7
pub effective_delay: u64,
8
pub proposal_deposit: Uint128,
9
pub voter_weight: Decimal,
10
pub snapshot_period: u64,
11
}
Copied!
1
{
2
"mirror_token": "terra1...",
3
"quorum": "0.1",
4
"threshold": "0.5",
5
"voting_period": 8,
6
"effective_delay": 8,
7
"proposal_deposit": "100000",
8
"voter_weight": "0.5",
9
"snapshot_period": 8
10
}
Copied!
Key
Type
Description
mirror_token
HumanAddr
Contract address of Mirror Token (MIR)
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
proposal_deposit
Uint128
Minimum MIR deposit required for a new poll to be submitted
effective_delay
u64
Number of blocks after a poll passes to apply changes
voter_weight
Decimal
Ratio of protocol fee which will be distributed among the governance poll voters
snapshot_period
u64
Minimum number of blocks before the end of voting period which snapshot could be taken to lock the current quorum for a poll

HandleMsg

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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
Receive {
5
amount: Uint128,
6
sender: HumanAddr,
7
msg: Option<Binary>,
8
}
9
}
Copied!
1
{
2
"receive": {
3
"amount": "10000000",
4
"sender": "terra1...",
5
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
6
}
7
}
Copied!
Key
Type
Description
amount
Uint128
Amount of tokens received
sender
HumanAddr
Sender of token transfer
msg*
Binary
Base64-encoded JSON of Receive Hook
* = optional

UpdateConfig

Updates the configuration for the Gov contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
UpdateConfig {
5
owner: Option<HumanAddr>,
6
quorum: Option<Decimal>,
7
threshold: Option<Decimal>,
8
voting_period: Option<u64>,
9
effective_delay: Option<u64>,
10
expiration_period: Option<u64>,
11
proposal_deposit: Option<Uint128>,
12
voter_weight: Option<Decimal>,
13
snapshot_period: Option<u64>,
14
}
15
}
Copied!
1
{
2
"update_config": {
3
"owner": "terra...1",
4
"mirror_token": "terra1...",
5
"quorum": "0.1",
6
"threshold": "0.5",
7
"voting_period": 8,
8
"effective_delay": 8,
9
"expiration_period": 8,
10
"proposal_deposit": "100000",
11
"voter_weight": "0.5",
12
"snapshot_period": 8
13
}
14
}
Copied!
Key
Type
Description
owner*
HumanAddr
Address of owner of governance contract
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
effective_delay*
u64
Number of blocks after a poll passes to apply changes
expiration_period*
u64
Number of blocks after a poll's voting period during which the poll can be executed
proposal_deposit*
Uint128
Minimum MIR deposit required for a new poll to be submitted
voter_weight*
Decimal
Ratio of protocol fee which will be distributed among the governance poll voters
snapshot_period*
u64
Minimum number of blocks before end of voting period which snapshot could be taken to lock the current quorum for a poll
* = optional

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.)
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
CastVote {
5
poll_id: u64,
6
vote: VoteOption,
7
amount: Uint128,
8
},
9
}
Copied!
1
{
2
"cast_vote": {
3
"amount": "1000000",
4
"poll_id": 8,
5
"vote": "yes/no/abstain"
6
}
7
}
Copied!
Key
Type
Description
amount
Uint128
Amount of voting power (staked MIR) to allocate
poll_id
u64
Poll ID
vote
VoteOption
Can be yes,no or abstain

WithdrawVotingTokens

Removes deposited MIR tokens from a staking position and returns them to a user's balance.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
WithdrawVotingTokens {
5
amount: Option<Uint128>,
6
}
7
}
Copied!
1
{
2
"withdraw_voting_tokens": {
3
"amount": "10000000"
4
}
5
}
Copied!
Key
Type
Description
amount*
Uint128
Amount of MIR tokens to withdraw. If empty, all staked MIR tokens are withdrawn.
* = optional

WithdrawVotingRewards

Withdraws a user’s voting reward for user’s voted governance poll after end_poll has happened.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
WithdrawVotingRewards {},
5
}
Copied!
1
{
2
"withdraw_voting_rewards": {}
3
}
Copied!

StakeVotingRewards

Immediately re-stakes user's voting rewards to Gov Contract.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
StakeVotingRewards {},
5
}
Copied!
1
{
2
"stake_voting_rewards": {}
3
}
Copied!

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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
EndPoll {
5
poll_id: u64,
6
}
7
}
Copied!
1
{
2
"end_poll": {
3
"poll_id": 8
4
}
5
}
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.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
ExecutePoll {
5
poll_id: u64,
6
}
7
}
Copied!
1
{
2
"execute_poll": {
3
"poll_id": 8
4
}
5
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

SnapshotPoll

Snapshot of poll’s current quorum status is saved when the block height enters snapshot_period.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum HandleMsg {
4
SnapshotPoll {
5
poll_id: u64,
6
}
7
}
Copied!
1
{
2
"snapshot_poll": {
3
"poll_id": 8
4
}
5
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

Receive Hooks

StakeVotingTokens

WARNING
If you send MIR tokens to the Gov contract without issuing this hook, they will not be staked and will be irrevocably donated to the reward pool for stakers.
Issued when sending MIR tokens to the Gov contract to add them to their MIR staking position.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum Cw20HookMsg {
4
StakeVotingTokens {}
5
}
Copied!
1
{
2
"stake_voting_tokens": {}
3
}
Copied!

CreatePoll

Issued when sending MIR tokens to the Gov contract to create a new poll. Will only succeed if the amount of tokens sent meets the configuredproposal_depositamount. Contains a generic message to be issued by the Gov contract if it passes (can invoke messages in other contracts it owns).
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum Cw20HookMsg {
4
CreatePoll {
5
description: String,
6
execute_msg: Option<ExecuteMsg>,
7
link: Option<String>,
8
title: String,
9
}
10
}
11
12
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
13
#[serde(rename_all = "snake_case")]
14
pub struct ExecuteMsg {
15
pub contract: HumanAddr,
16
pub msg: Binary,
17
}
Copied!
1
{
2
"create_poll": {
3
"description": "...",
4
"execute_msg": {
5
"contract": "terra1...",
6
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
7
},
8
"link": "...",
9
"title": "..."
10
}
11
}
Copied!
Key
Type
Description
description
string
Poll description
execute_msg*
ExecuteMsg
Message to be executed by Gov contract
link*
string
URL to external post about poll (forum, PDF, etc.)
title
string
Poll title
* = optional

DepositReward

Reward is distributed between MIR stakers and governance poll voters based on voter_weight when rewards are sent from Mirror Collector.
Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum Cw20HookMsg {
4
DepositReward {},
5
}
Copied!
1
{
2
"deposit_reward": {}
3
}
Copied!

QueryMsg

Config

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Config {}
5
}
Copied!

Response

1
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
2
pub struct ConfigResponse {
3
pub owner: HumanAddr,
4
pub mirror_token: HumanAddr,
5
pub quorum: Decimal,
6
pub threshold: Decimal,
7
pub voting_period: u64,
8
pub effective_delay: u64,
9
pub proposal_deposit: Uint128,
10
pub voter_weight: Decimal,
11
pub snapshot_period: u64,
12
}
Copied!
Key
Type
Description
mirror_token
HumanAddr
Contract address of Mirror Token (MIR)
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
effective_delay
u64
Number of blocks after a poll passes to apply changes
expiration_period
u64
Number of blocks after a poll's voting period during which the poll can be executed
proposal_deposit
Uint128
Minimum MIR deposit required for a new poll to be submitted
voter_weight
Decimal
Ratio of protocol fee which will be distributed among the governance poll voters
snapshot_period
u64
Minimum number of blocks before end of voting period which snapshot could be taken to lock the current quorum for a poll
1
{
2
"config": {}
3
}
Copied!

Response

1
{
2
"config_response": {
3
"owner": "terra1...",
4
"mirror_token": "terra1...",
5
"quorum": "0.1",
6
"threshold": "0.5",
7
"voting_period": 100000,
8
"effective_delay": 13000,
9
"proposal_deposit": "1000000",
10
"voter_weight": "0.5",
11
"snapshot_period": 1000
12
}
13
}
Copied!
Key
Type
Description
mirror_token
HumanAddr
Contract address of Mirror Token (MIR)
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
effective_delay
u64
Number of blocks after a poll passes to apply changes
proposal_deposit
Uint128
Minimum MIR deposit required for a new poll to be submitted
voter_weight
Decimal
Ratio of protocol fee which will be distributed among the governance poll voters
snapshot_period
u64
Minimum number of blocks before end of voting period which snapshot could be taken to lock the current quorum for a poll

State

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
State {}
5
}
Copied!

Response

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
pub pending_voting_rewards: Uint128,
7
}
Copied!
Key
Type
Description
poll_count
u64
Total number of polls that have been created on Mirror Protocol
total_share
Uint128
Amount of staked MIR to governance contract
total_deposit
Uint128
Amount of locked MIR to governance polls
pending_voting_rewards
Uint128
Amount of voting rewards that are not claimed yet
1
{
2
"state": {}
3
}
Copied!

Response

1
{
2
"state_response": {
3
"poll_count": 100,
4
"total_share": "1000000",
5
"total_deposit": "1000000",
6
"pending_voting_rewards": "1000000"
7
}
8
}
Copied!
Key
Type
Description
poll_count
u64
Total number of polls that have been created on Mirror Protocol
total_share
Uint128
Amount of staked MIR to governance contract
total_deposit
Uint128
Amount of locked MIR to governance polls
pending_voting_rewards
Uint128
Amount of voting rewards that are not claimed yet

Staker

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Staker {
5
address: HumanAddr,
6
}
7
}
Copied!
Key
Type
Description
address
HumanAddr
Address of staker

Response

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)>,
6
pub pending_voting_rewards: Uint128,
7
}
Copied!
Key
Type
Description
balance
Uint128
Amount of MIR staked by the user
share
Uint128
Weight of the user's staked MIR
locked_balance
Vec<(u64, VoterInfo)>
Total number of staked MIR used as votes, and chosen vote option
pending_voting_rewards
u64
Amount of voting rewards that are not claimed yet
1
{
2
"staker": {
3
"address": "terra1..."
4
}
5
}
Copied!
Key
Type
Description
address
HumanAddr
Address of staker

Response

1
{
2
"staker_response": {
3
"balance": "1000000",
4
"share": "1000000",
5
"locked_balance": [
6
[100, yes, "1000000"],
7
[100, abstain, "1000000"]
8
]
9
"pending_voting_rewards": "1000000"
10
}
11
}
Copied!
Key
Type
Description
balance
Uint128
Amount of MIR staked by the user
share
Uint128
Weight of the user's staked MIR
locked_balance
Vec<(u64, VoterInfo)>
Total number of staked MIR used as votes, and chosen vote option
pending_voting_rewards
u64
Amount of voting rewards that are not claimed yet

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!
Key
Type
Description
poll_id
u64
Poll ID

Response

1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct PollResponse {
3
pub id: u64,
4
pub creator: HumanAddr,
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<ExecuteMsg>,
12
pub yes_votes: Uint128, // balance
13
pub no_votes: Uint128, // balance
14
pub abstain_votes: Uint128, // balance
15
pub total_balance_at_end_poll: Option<Uint128>,
16
pub voters_reward: Uint128,
17
pub staked_amount: Option<Uint128>,
18
}
Copied!
Key
Type
Description
id
u64
Poll ID
creator
HumanAddr
Address of the poll creator
status
PollStatus
Could be one of "in progress", "rejected", "passed", "executed", "expired"
end_height
u64
Amount of voting rewards that are not claimed yet
title
String
Title of the poll
description
String
Description submitted by the creator
link*
Uint128
URL link
deposit_amount
binary
Initial MIR deposit at poll creation
execute_data*
ExecuteMsg
Message to be executed by Gov contract
yes_votes
Uint128
Amount of yes votes
no_votes
Uint128
Amount of no votes
abstain_votes
Uint128
Amount of abstain votes
total_balance_at_end_poll*
Uint128
Total balanced used as yes, no, or abstain votes at the end of the poll
voters_reward
Uint128
Amount of MIR reward accumulated to be distributed to the voters
staked_amount*
Uint128
Total number of MIR staked on governance contract (used when Snapshot Poll has been taken)
1
{
2
"poll": {
3
"poll_id": 8
4
}
5
}
Copied!
Key
Type
Description
poll_id
u64
Poll ID

Response

1
{
2
"poll_response": {
3
"id": 8,
4
"creator": "terra1...",
5
"status": "in_progress",
6
"end_height": 1000000,
7
"title": "Register mCOIN Parameters",
8
"description": "mCOIN has been...",
9
"link": "https://mirror.finance",
10
"deposit_amount": "1000000",
11
"execute_data": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9",
12
"yes_votes": "1000000",
13
"no_votes": "1000000",
14
"abstain_votes": "1000000",
15
"total_balance_at_end_poll": "1000000",
16
"voters_reward": "1000000",
17
"staked_amount": "1000000"
18
}
19
}
Copied!
Key
Type
Description
id
u64
Poll ID
creator
HumanAddr
Address of the poll creator
status
PollStatus
Could be one of "in progress", "rejected", "passed", "executed", "expired"
end_height
u64
Amount of voting rewards that are not claimed yet
title
String
Title of the poll
description
String
Description submitted by the creator
link*
Uint128
URL link
deposit_amount
binary
Initial MIR deposit at poll creation
execute_data*
ExecuteMsg
Message to be executed by Gov contract
yes_votes
Uint128
Amount of yes votes
no_votes
Uint128
Amount of no votes
abstain_votes
Uint128
Amount of abstain votes
total_balance_at_end_poll*
Uint128
Total balanced used as yes, no, or abstain votes at the end of the poll
voters_reward
Uint128
Amount of MIR reward accumulated to be distributed to the voters
staked_amount*
Uint128
Total number of MIR staked on governance contract (used when Snapshot Poll has been taken)

Polls

Rust
JSON
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
limit: Option<u32>,
7
start_after: Option<u64>,
8
}
9
}
Copied!
Key
Type
Description
filter*
PollStatus
Can be yes or no
limit*
u32
Limit of results to fetch
start_after*
u64
Begins search query at specific ID
* = optional

Response

1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct PollsResponse {
3
pub polls: Vec<PollResponse>,
4
}
Copied!
Key
Type
Description
polls
Vec<PollResponse>
Array of poll query responses
1
{
2
"polls": {
3
"filter": "in_progress",
4
"limit": 8,
5
"start_after": 8
6
}
7
}
Copied!
Key
Type
Description
filter*
PollStatus
Can be yes or no
limit*
u32
Limit of results to fetch
start_after*
u64
Begins search query at specific ID
* = optional

Response

1
{
2
"polls_response": {
3
"polls": [
4
"poll_response": {
5
"id": 8,
6
"creator": "terra1...",
7
"status": "in_progress",
8
"end_height": 1000000,
9
"title": "Register mCOIN Parameters",
10
"description": "mCOIN has been...",
11
"link": "https://mirror.finance",
12
"deposit_amount": "1000000",
13
"execute_data": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9",
14
"yes_votes": "1000000",
15
"no_votes": "1000000",
16
"abstain_votes": "1000000",
17
"total_balance_at_end_poll": "1000000",
18
"voters_reward": "1000000",
19
"staked_amount": "1000000"
20
}
21
...
22
]
23
}
24
}
Copied!
Key
Type
Description
polls
Vec<PollResponse>
Array of poll query responses

Voters

Rust
JSON
1
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
2
#[serde(rename_all = "snake_case")]
3
pub enum QueryMsg {
4
Voters {
5
limit: Option<u32>,
6
poll_id: u64,
7
start_after: Option<HumanAddr>,
8
}
9
}
Copied!
Key
Type
Description
limit*
u32
Limit of results to fetch
poll_id
u64
Poll ID
start_after*
HumanAddr
Begins search query with prefix
* = optional

Response

1
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
2
pub struct VotersResponseItem {
3
pub voter: HumanAddr,
4
pub vote: VoteOption,
5
pub balance: Uint128,
6
}
Copied!
Key
Type
Description
voter
HumanAddr
Address of the voter
vote
VoteOption
Could be one of yes, no, abstain
balance
Uint128
Amount of staked MIR used for voting
1
{
2
"voters": {
3
"limit": 8,
4
"poll_id": 8,
5
"start_after": "terra1..."
6
}
7
}
Copied!
Key
Type
Description
limit*