Valkyrie Protocol
Search
⌃K

Governance

The Gov Contract contains logic for holding polls and Valkyrie Token (VKR) staking, and allows the Valkyrie Protocol to be governed by its users in a decentralized manner.
New proposals for change are submitted as polls, and are voted on by VKR stakers through the Poll Lifecycle. Polls can contain messages that can be executed directly without changing the Valkyrie Protocol code.

InstantiateMsg

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub contract_config: ContractConfigInitMsg,
pub poll_config: PollConfigInitMsg,
}
{
"contract_config":{
"governance_token": "terra1..."
},
"poll_config":{
"quorum": "0.4",
"threshold": "0.5",
"voting_period": 8,
"execution_delay_period": 0,
"proposal_deposit": "1000000",
"snapshot_period":0
},
}
Key
Type
Description
contract_config
ContractConfigInitMsg
Contract init configuration message
poll_config
PollConfigInitMsg
Poll init configuration message

ContractConfigInitMsg

.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ContractConfigInitMsg {
pub governance_token: String,
}
{
"contract_config_init_msg":{
"governance_token": "terra1..."
}
}
Key
Type
Description
governanace_token
String
Contract address of Valkyrie Token (VKR)

PollConfigInitMsg

.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct PollConfigInitMsg {
pub quorum: Decimal,
pub threshold: Decimal,
pub voting_period: u64,
pub execution_delay_period: u64,
pub proposal_deposit: Uint128,
pub snapshot_period: u64,
}
{
"poll_config_init_msg":{
"quorum": "0.4",
"threshold": "0.5",
"voting_period": 8,
"execution_delay_period": 0,
"proposal_deposit": "1000000",
"snapshot_period":0
}
}
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
execution_delay_period
u64
Number of blocks after a poll's voting period during which the poll can be executed.
proposal_deposit
Uint128
Minimum VKR deposit required for a new poll to be submitted
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

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.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Receive {
amount: Uint128,
sender: Addr,
msg: Option<Binary>,
}
}
{
"receive": {
"amount": "10000000",
"sender": "terra1...",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}
Key
Type
Description
Cw20ReceiveMsg
Uint128
Amount of tokens received
sender
Addr
Sender of token transfer
msg*
Binary
Base64-encoded JSON of receive hook
* = optional

UpdatePollConfig

Updates the configuration for the Gov contract.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
UpdatePollConfig {
quorum: Option<Decimal>,
threshold: Option<Decimal>,
voting_period: Option<u64>,
execution_delay_period: Option<u64>,
proposal_deposit: Option<Uint128>,
snapshot_period: Option<u64>,
}
}
{
"update_poll_config": {
"quorum": "123.456789",
"threshold": "123.456789",
"voting_period": 8,
"execution_delay_period": 8,
"proposal_deposit": "10000000",
"snapshot_period": 8
}
}
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
execution_delay_period*
u64
Number of blocks after a poll passes to apply changes
proposal_deposit*
Uint128
Minimum VKR deposit required for a new poll to be submitted
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
* = 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
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
CastVote {
amount: Uint128,
poll_id: u64,
vote: VoteOption,
}
}
{
"cast_vote": {
"amount": "10000000",
"poll_id": 8,
"vote": "yes/no"
}
}
Key
Type
Description
amount
Uint128
Amount of voting power (staked VKR) to allocate
poll_id
u64
Poll ID
vote
VoteOption
Could be one of yes, no, abstain

UnstakeGovernanceToken

Removes deposited VKR tokens from a staking position and returns them to a user's balance.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
UnstakeGovernanceToken {
amount: Option<Uint128>,
}
}
{
"unstake_governance_token": {
"amount": "10000000"
}
}
Key
Type
Description
amount*
Uint128
Amount of VKR tokens to withdraw. If empty, all staked VKR tokens are withdrawn.
* = 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.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
EndPoll {
poll_id: u64,
}
}
{
"end_poll": {
"poll_id": 8
}
}
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
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
ExecutePoll {
poll_id: u64,
}
}
{
"execute_poll": {
"poll_id": 8
}
}
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
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
SnapshotPoll {
poll_id: u64,
}
}
{
"snapshot_poll": {
"poll_id": 8
}
}
Key
Type
Description
poll_id
u64
Poll ID

RunExecution

This ExecuteMsg is only used as sub messages to ExecutePoll
To execute or roll back all ExecutionMsgs together, ExecuteMsg executes executions of Poll through RunExecution.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
RunExecution {
executions: Vec<ExecutionMsg>
}
}
{
"run_execution": {
"executions": [{}]
}
}
Key
Type
Description
executions
Vec<ExecutionMsg>
Execution messages

Receive Hooks

StakeGovernanceToken

WARNING
If you send VKR 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 VKR tokens to the Gov contract to add them to their VKR staking position.
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
StakeGovernanceToken {}
}
{
"stake_governance_token": {}
}

CreatePoll

Issued when sending VKR 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. Contains a generic message to be issued by the Gov contract if it passes (can invoke messages in other contracts it owns).
Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
CreatePoll {
title: String,
description: String,
link: Option<String>,
executions: Vec<ExecuteMsg>,
}
}
{
"create_poll": {
"title": "..."
"description": "...",
"link": "...",
"executions": [
{
"contract": "terra1...",
"msg": "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}..
],
​
​
}
}
Key
Type
Description
title
String
Poll title
description
String
Poll description
link*
String
URL to external post about poll (forum, PDF, etc.)
executions
Vec(ExecutionMsg)
Message to be executed by Gov contract
* = optional

QueryMsg

ContractConfig

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
ContractConfig {}
}
{
"contract_config": {}
}

Response

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct ContractConfigResponse {
pub governance_token: String,
}
{
"contract_config_response": {
"governance_token": "terra1..."
}
}
Key
Type
Description
governance_token
String
Contract address of governance token

PollConfig

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Pollconfig {}
}
{
"poll_config": {}
}

Response

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct PollConfigResponse {
pub quorum: Decimal,
pub threshold: Decimal,
pub voting_period: u64,
pub execution_delay_period: u64,
pub proposal_deposit: Uint128,
pub snapshot_period: u64,
}
{
"poll_config_response": {
"quorum": "0.1",
"threshold": "0.5",
"voting_period": 100000,
"execution_delay_period": 13000,
"proposal_deposit": "1000000",
"snapshot_period": 1000
}
}
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
execution_delay_period
u64
Number of blocks after a poll passes to apply changes
proposal_deposit
Uint128
Minimum VKR deposit required for a new poll to be submitted
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
* = optional

PollState

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
PollState {}
}
{
"poll_state": {}
}

Response

Rust
JSON
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct PollStateResponse {
pub poll_count: u64,
pub total_deposit: Uint128,
}
{
"poll_state_response": {
"poll_count": 100,
"total_deposit": "1000000"
}
}
Key
Type
Description
poll_count
u64
Total number of polls that have been created on Valkyrie Protocol
total_deposit
Uint128
Amount of locked VKR to governance polls

Poll

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Poll {
poll_id: u64,
}
}
{
"poll": {
"poll_id": 8
}
}
Key
Type
Description
poll_id
u64
Poll ID

Response

Rust
JSON
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
pub struct PollResponse {
pub id: u64,
pub title: String,
pub description: String,
pub link: Option<String>,
pub executions: Option<Vec<ExecutionMsg>>,
pub creator: String,
pub deposit_amount: Uint128,
pub yes_votes: Uint128,
pub no_votes: Uint128,
pub abstain_votes: Uint128,
pub end_height: u64,
pub status: PollStatus,
pub staked_amount: Option<Uint128>,
pub total_balance_at_end_poll: Option<Uint128>,
}
{
"poll_response": {
"id": 1,
"title": ".....",
"description": "....",
"link": "https://app.valkyrieprotocol.money",
"executions": [{ExecutionMsg}],
"creator": "terra1...",
"deposit_amount": 1000000,
"yes_votes": 1000000,
"no_votes": 1000000,
"abstain_votes": 1000000,
"end_height": 1000000,
"status": "in_progress",
"staked_amount": 1000000
"total_balance_at_end_poll": 1000000
}
}
Key
Type
Description
id
u64
Poll ID
title
String
Title of the poll
description
String
Description submitted by the creator
link*
String
URL link
executions
Vec(ExecutionMsg)
Message to be executed by Gov contract
creator
String
Address of the poll creator
deposit_amount
Uint128
Initial VKR deposit at poll creation
yes_votes
Uint128
Amount of yes votes
no_votes
Uint128
Amount of no votes
abstain_vote
Uint128
Amount of abstain votes
end_height
u64
Amount of voting rewards that are not claimed yet
status
PollStatus
Could be one of in progress, rejected, passed, executed, expired
staked_amount*
Uint128
Total number of VKR staked on governance contract (used when Snapshot Poll has been taken)
total_balance_at_end_poll*
Uint128
Total balanced used as yes, no, or abstain votes at the end of the poll
*=optional

Polls

Rust
JSON
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
Polls {
filter: Option<PollStatus>,
start_after: Option<u64>,
limit: Option<u32>,
order_by: Option<OrderBy>,
}
}
{
"polls": {
"filter": "in_progress",
"start_after": 8,
"limit": 8,
"order_by": "dec"
}
}
Key
Type
Description
filter*
PollStatus
Could be one of in progress, rejected, passed, executed, expired
start_after*
String
Begins search query at specific ID
limit*
u32
Limit of results to fetch
order_by*
OrderBy
Order to make query
*=optional

Response

Rust
JSON
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
pub struct PollsResponse {
pub polls: Vec<PollResponse>,
}
{
"polls_response": {
"polls": [
{
"id": 1,