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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct InstantiateMsg {
pub contract_config : ContractConfigInitMsg ,
pub poll_config : PollConfigInitMsg ,
}
Copy {
"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
} ,
}
Contract init configuration message
Poll init configuration message
ContractConfigInitMsg
.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
pub struct ContractConfigInitMsg {
pub governance_token : String ,
}
Copy {
"contract_config_init_msg" :{
"governance_token" : "terra1..."
}
}
Contract address of Valkyrie Token (VKR)
PollConfigInitMsg
.
Rust JSON
Copy #[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 ,
}
Copy {
"poll_config_init_msg" :{
"quorum" : "0.4" ,
"threshold" : "0.5" ,
"voting_period" : 8 ,
"execution_delay_period" : 0 ,
"proposal_deposit" : "1000000" ,
"snapshot_period" : 0
}
}
Minimum percentage of participation required for a poll to pass
Minimum percentage of yes
votes required for a poll to pass
Number of blocks during which votes can be cast
Number of blocks after a poll's voting period during which the poll can be executed.
Minimum VKR deposit required for a new poll to be submitted
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
Receive {
amount : Uint128 ,
sender : Addr ,
msg : Option < Binary >,
}
}
Copy {
"receive" : {
"amount" : "10000000" ,
"sender" : "terra1..." ,
"msg" : "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}
}
Amount of tokens received
Base64-encoded JSON of receive hook
* = optional
UpdatePollConfig
Updates the configuration for the Gov contract.
Rust JSON
Copy #[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 >,
}
}
Copy {
"update_poll_config" : {
"quorum" : "123.456789" ,
"threshold" : "123.456789" ,
"voting_period" : 8 ,
"execution_delay_period" : 8 ,
"proposal_deposit" : "10000000" ,
"snapshot_period" : 8
}
}
Minimum percentage of participation required for a poll to pass
Minimum percentage of yes
votes required for a poll to pass
Number of blocks during which votes can be cast
Number of blocks after a poll passes to apply changes
Minimum VKR deposit required for a new poll to be submitted
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
CastVote {
amount : Uint128 ,
poll_id : u64 ,
vote : VoteOption ,
}
}
Copy {
"cast_vote" : {
"amount" : "10000000" ,
"poll_id" : 8 ,
"vote" : "yes/no"
}
}
Amount of voting power (staked VKR) to allocate
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
UnstakeGovernanceToken {
amount : Option < Uint128 >,
}
}
Copy {
"unstake_governance_token" : {
"amount" : "10000000"
}
}
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
EndPoll {
poll_id : u64 ,
}
}
Copy {
"end_poll" : {
"poll_id" : 8
}
}
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
ExecutePoll {
poll_id : u64 ,
}
}
Copy {
"execute_poll" : {
"poll_id" : 8
}
}
SnapshotPoll
Snapshot of poll’s current quorum
status is saved when the block height enters snapshot_period
.
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
SnapshotPoll {
poll_id : u64 ,
}
}
Copy {
"snapshot_poll" : {
"poll_id" : 8
}
}
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum ExecuteMsg {
RunExecution {
executions : Vec < ExecutionMsg >
}
}
Copy {
"run_execution" : {
"executions" : [{}]
}
}
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum Cw20HookMsg {
StakeGovernanceToken {}
}
Copy {
"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
Copy #[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 >,
}
}
Copy {
"create_poll" : {
"title" : "..."
"description" : "..." ,
"link" : "..." ,
"executions" : [
{
"contract" : "terra1..." ,
"msg" : "eyAiZXhlY3V0ZV9tc2ciOiAiYmxhaCBibGFoIiB9"
}..
] ,
}
}
URL to external post about poll (forum, PDF, etc.)
Message to be executed by Gov contract
* = optional
QueryMsg
ContractConfig
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
ContractConfig {}
}
Copy {
"contract_config" : {}
}
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , PartialEq , JsonSchema )]
pub struct ContractConfigResponse {
pub governance_token : String ,
}
Copy {
"contract_config_response" : {
"governance_token" : "terra1..."
}
}
Contract address of governance token
PollConfig
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Pollconfig {}
}
Copy {
"poll_config" : {}
}
Response
Rust JSON
Copy #[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 ,
}
Copy {
"poll_config_response" : {
"quorum" : "0.1" ,
"threshold" : "0.5" ,
"voting_period" : 100000 ,
"execution_delay_period" : 13000 ,
"proposal_deposit" : "1000000" ,
"snapshot_period" : 1000
}
}
Minimum percentage of participation required for a poll to pass
Minimum percentage of yes
votes required for a poll to pass
Number of blocks during which votes can be cast
Number of blocks after a poll passes to apply changes
Minimum VKR deposit required for a new poll to be submitted
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
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
PollState {}
}
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , PartialEq , JsonSchema )]
pub struct PollStateResponse {
pub poll_count : u64 ,
pub total_deposit : Uint128 ,
}
Copy {
"poll_state_response" : {
"poll_count" : 100 ,
"total_deposit" : "1000000"
}
}
Total number of polls that have been created on Valkyrie Protocol
Amount of locked VKR to governance polls
Poll
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Poll {
poll_id : u64 ,
}
}
Copy {
"poll" : {
"poll_id" : 8
}
}
Response
Rust JSON
Copy #[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 >,
}
Copy {
"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
}
}
Description submitted by the creator
Message to be executed by Gov contract
Address of the poll creator
Initial VKR deposit at poll creation
Amount of voting rewards that are not claimed yet
Could be one of in progress
, rejected
, passed
, executed
, expired
Total number of VKR staked on governance contract (used when Snapshot Poll has been taken)
total_balance_at_end_poll*
Total balanced used as yes, no, or abstain votes at the end of the poll
*=optional
Polls
Rust JSON
Copy #[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 >,
}
}
Copy {
"polls" : {
"filter" : "in_progress" ,
"start_after" : 8 ,
"limit" : 8 ,
"order_by" : "dec"
}
}
Could be one of in progress
, rejected
, passed
, executed
, expired
Begins search query at specific ID
Limit of results to fetch
*=optional
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Debug , Clone , PartialEq , JsonSchema )]
pub struct PollsResponse {
pub polls : Vec < PollResponse >,
}
Copy {
"polls_response" : {
"polls" : [
{
"id" : 1 ,
"title" : "....." ,
"description" : "...." ,
"link" : "https://valkyrie.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"
} ,
...
]
}
}
Array of poll query responses
Voters
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
Voters {
poll_id : u64 ,
start_after : Option < String >,
limit : Option < u32 >,
order_by : Option < OrderBy >,
}
}
Copy {
"voters" : {
"poll_id" : 3 ,
"start_after" : " " ,
"limit" : 3 ,
"order_by" : "dec" ,
}
}
Begins search query at specific ID
Limit of results to fetch
*=optional
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Debug , Clone , PartialEq , JsonSchema )]
pub struct VotersResponse {
pub voters : Vec < VoteInfoMsg >,
}
Copy {
"voters_response" : {
"voters" : [{
"voter" : "terra1..." ,
"option" : "yes" ,
"amount" : 100 ,
} , ...
]
}
}
StakingState
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
StakingState {}
}
Copy {
"staking_state" : {}
}
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , PartialEq , JsonSchema )]
pub struct StakingStateResponse {
pub total_share : Uint128 ,
}
Copy {
"staking_state_response" : {
"total_share" : 1
}
}
Amount of staked VKR to governance contract
StakerState
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
StakerState {
address : String
}
}
Copy {
"staker_state" : {
"address" : "...."
}
}
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , PartialEq , JsonSchema )]
pub struct StakerStateResponse {
pub balance : Uint128 ,
pub share : Uint128 ,
pub votes : Vec <( u64 , VoteInfoMsg )>,
}
Copy {
"staker_state_response" : {
"balance" : 100 ,
"share" : 100000 ,
"votes" : [( 1 , { "voter" : "terra1..." , "option" : "yes" , "amount" : 100 , }) ... ]
}
}
Amount of staked VKR used for voting
Weight of the user's staked VKR
Could be one of yes
, no
, abstain
VotingPower
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , Debug , PartialEq , JsonSchema )]
#[serde(rename_all = "snake_case" )]
pub enum QueryMsg {
VotingPower {
address : String
}
}
Copy {
"voting_power" : {
"address" : "...."
}
}
Response
Rust JSON
Copy #[derive( Serialize , Deserialize , Clone , PartialEq , JsonSchema )]
pub struct VotingPowerResponse {
pub voting_power : Decimal
}
Copy {
"voting_power_response" : {
"voting_power" : 100
}
}
The number of votes voted on poll