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

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub contract_config: ContractConfigInitMsg,
    pub poll_config: PollConfigInitMsg,
}

Key

Type

Description

contract_config

ContractConfigInitMsg

Contract init configuration message

poll_config

PollConfigInitMsg

Poll init configuration message

ContractConfigInitMsg

.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ContractConfigInitMsg {
    pub governance_token: String,
}

Key

Type

Description

governanace_token

String

Contract address of Valkyrie Token (VKR)

PollConfigInitMsg

.

#[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,
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    Receive {
        amount: Uint128,
        sender: Addr,
        msg: Option<Binary>,
    }
}

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.

#[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>,
    }
}

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.)

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    CastVote {
        amount: Uint128,
        poll_id: u64,
        vote: VoteOption,
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    UnstakeGovernanceToken {
        amount: Option<Uint128>,
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    EndPoll {
        poll_id: u64,
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    ExecutePoll {
        poll_id: u64,
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    SnapshotPoll {
        poll_id: u64,
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    RunExecution {
        executions: Vec<ExecutionMsg>
    }
}

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.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum Cw20HookMsg {
    StakeGovernanceToken {}
}

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).

#[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>,
    }
}

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

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

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct ContractConfigResponse {
    pub governance_token: String,
}

Key

Type

Description

governance_token

String

Contract address of governance token

PollConfig

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

Response

#[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,
}

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

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

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct PollStateResponse {
    pub poll_count: u64,
    pub total_deposit: Uint128,
}

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

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Poll {
        poll_id: u64,
    }
}

Key

Type

Description

poll_id

u64

Poll ID

Response

#[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>,
}

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

#[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>,
    }
}

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

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

Key

Type

Description

polls

Vec<PollResponse>

Array of poll query responses

Voters

#[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>,
    }
}

Key

Type

Description

poll_id

u64

Poll ID

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

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema)]
pub struct VotersResponse {
    pub voters: Vec<VoteInfoMsg>,
}

Key

Type

Description

voters

Vec<VoteInfoMsg>

List of vote info Msg

StakingState

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    StakingState {}
}

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct StakingStateResponse {
    pub total_share: Uint128,
}

Key

Type

Description

total_share

Uint128

Amount of staked VKR to governance contract

StakerState

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    StakerState { 
        address: String 
    }
}

Key

Type

Description

address

String

Address of staker wallet

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct StakerStateResponse {
    pub balance: Uint128,
    pub share: Uint128,
    pub votes: Vec<(u64, VoteInfoMsg)>,
}

Key

Type

Description

balance

Uint128

Amount of staked VKR used for voting

share

Uint128

Weight of the user's staked VKR

votes

Vec<(u64, VoteInfoMsg)>

Could be one of yes, no, abstain

VotingPower

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    VotingPower { 
        address: String 
    }
}

Key

Type

Description

address

String

Address of voter wallet

Response

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct VotingPowerResponse {
    pub voting_power: Decimal
}

Key

Type

Description

voting_power

Decimal

The number of votes voted on poll

Last updated