Pharo
  • 🟢Getting Started
  • 🤝Meet Pharo
    • ❔Why Pharo
    • 🌪️Use Cases
    • 📐Architecture
  • ✨Protocol
    • 🎨Product Design
    • 💰Pricing Models
    • 🏛️Capitol Provision
    • 📊Risk Assessment
  • 🛣️Roadmap
  • ⁉️FAQs
  • Market Manager
    • 💹Creating a Pharo Market
    • 👩‍💼Managing a Market
  • Liquidity Provider
    • 🎯Selecting a Market
    • 💵Provide Liquidity
  • Cover Buyer
    • 🤔What it means to buy cover
    • 🔅Buy Cover
  • Governance
    • Overview
    • Process
      • 📄Writing A Proposal
    • Glossary
    • Adversarial Circumstances
    • Governance Reference
  • PHRO Token
    • Overview
    • 🪙Tokenomics
    • Staking
    • 📄Contracts
    • 🐪PHRO Distribution Speed
  • Guides
  • Beginners Guide to Voting
  • Setting Up Your Local Environment
    • Hardhat
    • Foundry
  • API Reference
    • Start Here Developer
  • Technical Reference
    • Litepaper
    • Smart Contracts Overview
    • Pharo SDK
    • Anubis
    • Obelisk
Powered by GitBook
On this page
  • Timelock
  • Key Events
  • Delegate Changed
  • DelegateVotesChanged
  • PropsalCreated
  • VoteCast
  • ProposalCancelled
  • ProposalQueued
  • ProposalExecuted
  • Read-Only Functions: PHRO
  • Get Current Votes
  • Get Prior Votes
  • State-Changing Functions: gPHRO
  • Delegate
  • Delegate By Signature
  • Read-Only Functions: Governor Alpha
  • Quorum Votes
  • Proposal Threshold
  • Proposal Max Operations
  • Voting Delay
  • Voting Period
  • Get Actions
  • Get Receipt
  • State
  • State-Changing Functions: Governor Alpha
  • Propose
  • Queue
  • Execute
  • Cancel
  • Cast Vote
  • Cast Vote By Signature

Was this helpful?

  1. Governance

Governance Reference

PreviousAdversarial CircumstancesNextOverview

Last updated 1 year ago

Was this helpful?

Pharo protocol is governed and upgraded by PHRO token holders, using three distinct components; the PHRO token, governance module and timelock. Together these contracts allow the community to propose, vote, and implement changes to the Pharo protocol.

Any addresses with more than 10M gPHRO delegated to it may propose governance actions.

Timelock

The Timelock contract can modify system parameters, logic, and contracts in a 'time-delayed, opt-out' upgrade pattern. Timelock has a hard-coded minimum delay of 2 days, which is the least amount of notice possible for a governance action. Each proposed action will be published at a minimum of 2 days in the future from the time of announcement. Major upgrades, such as changing the risk system, may have up to a 30 day delay. Timelock is controlled by the governance module; pending and completed governance actions can be monitored on the Timelock Dashboard (coming soon!).

Key Events

Delegate Changed

DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate)

Emitted when an account changes delegate.

DelegateVotesChanged

DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance)

Emitted when a delegate account's vote balance changes.

PropsalCreated

ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description)

Emitted when a new proposal is created.

VoteCast

VoteCast(address voter, uint proposalId, bool support, uint votes)

Emitted when a vote has been casted on a proposal.

ProposalCancelled

ProposalCanceled(uint id)

Emitted when a proposal has been cancelled.

ProposalQueued

ProposalQueued(uint id, uint eta)

Emitted when a proposal has been queued.

ProposalExecuted

ProposalExecuted(uint id)

Emitted when a proposal has been executed in the timelock.

Read-Only Functions: PHRO

Get Current Votes

function getCurrentVotes(address account) returns (uint96)

Returns the balance of votes for an account as of the current block.

Name

Type

account

address

Address of the account of which to retrieve the number of votes.

Solidity

PHRO phro = PHRO(0x123...); // contract address
uint votes = phro.getCurrentVotes(0xabc...);

Web3

const account = '0x123...'; // user address
const votes = await phro.methods.getCurrentVotes(account).call();

Get Prior Votes

function getPriorVotes(address account, uint blockNumber) returns (uint96)

Returns the prior number of votes for an account at a specific block number. The block number passed must be a finalized block or the function will revert.

Name

Type

account

address

Address of the account of which to retrieve the prior number of votes.

blocknumber

uint

The block number at which to retrieve the prior number of votes.

RETURN

uint96

The number of prior votes

Solidity

PHRO phro = PHRO(0x123...); // contract address
uint priorVotes = phro.getPriorVotes(0xabc..., blockNumber);

Web3

const priorVotes = await phro.methods.getCurrentVotes(account, blockNumber).call();

State-Changing Functions: gPHRO

Delegate

function delegate(address delegatee)

Delegate votes from the sender to the delegatee. Users can delegate to 1 address at a time, and the number of votes added to the delegatee’s vote count is equivalent to the balance of gPHRO in the user’s account. Votes are delegated from the current block and onward, until the sender delegates again, or transfers their gPHRO.

Name

Type

delegatee

address

The address to which msg.sender wishes to delegate to.

RETURN

no

Reverts on error.

Solidity

PHRO phro = PHRO(0x123...); // contract address
phro.delegate(delegateeAddress);

Web3

const tx = await phro.methods.delegate(delegateeAddress).send({ from: sender });

Delegate By Signature

function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s)

Delegate votes from the sender to the delegatee. Users can delegate to 1 address at a time, and the number of votes added to the delegatee’s vote count is equivalent to the balance of gPHRO in the user’s account. Votes are delegated from the current block and onward, until the sender delegates again, or transfers their gPHRO.

Name

Type

delegatee

address

The address to which msg.sender wishes to delegate to.

nonce

uint

The contract state required to match the signature. This can be retrieved from the contract's public nonces mapping.

expiry

uint

The time when the signature expires. A block timestamp in seconds since the UNIX epoch.

v

uint

The recovery byte of the signature.

r

bytes32

Half of the ECDSA signature pair.

s

bytes32

Half of the ECDSA signature pair.

RETURN

no

Reverts on error.

Solidity

PHRO phro = PHRO(0x123...); // contract address
phro.delegateBySig(delegateeAddress, nonce, expiry, v, r, s);

Web3

const tx = await phro.methods.delegateBySig(delegateeAddress, nonce, expiry, v, r, s).send({});

Read-Only Functions: Governor Alpha

Quorum Votes

function quorumVotes() public pure returns (uint)

Returns the minimum number of votes required for a proposal to succeed.

Solidity

GovernorAlpah gov = GovernorAlpha(0x123...); // contract address
uint quorum = gov.quorumVotes();

Web3

const quorum = await gov.methods.quorumVotes().call();

Proposal Threshold

function proposalThreshold() returns (uint)

Returns the minimum number of votes for an account to create a proposal.

Solidity

GovernorAlpha gov = GovernorAlpah(0x123...); // contract address
uint threshold = gov.proposalThreshold();

Web3

const threshold = await gov.methods.proposalThreshold().call();

Proposal Max Operations

function proposalMaxOperations() returns (uint)

Returns the maximum number of actions that can be included in a proposal. Actions are function calls that will be made when a proposal succeeds and executes.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
uint operations = gov.proposalMaxOperations();

Web3

const operations = await gov.methods.proposalMaxOperations().call();

Voting Delay

function votingDelay() returns (uint)

Returns the number of blocks to wait before voting on a proposal may begin. This value is added to the current block number when a proposal is created.

Solidity

GovernorAlpha gov = GovernorAlphaconst blocks = await gov.methods.votingPeriod().call();
(0x123...); // contract address
uint blocks = gov.votingDelay();

Web3

const blocks = await gov.methods.votingDelay().call();

Voting Period

function votingPeriod() returns (uint)

Returns the duration of voting on a proposal, in blocks.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
uint blocks = gov.votingPeriod();

Web3

const blocks = await gov.methods.votingPeriod().call();

Get Actions

function getActions(uint proposalId) returns (uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas)

Gets the actions of a selected proposal. Pass a proposal ID and get the targets, values, signatures and calldatas of that proposal.

Name

Type

proposalid

uint

ID of the proposal.

Returns:

  • Array of addresses of contracts the proposal calls.

  • Array of unsigned integers the proposal uses as values.

  • Array of strings of the proposal's signatures.

  • Array of calldata bytes of the proposal.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
uint proposalId = 123;
(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) = gov.getActions(proposalId);

Web3

const {0: targets, 1: values, 2: signatures, 3: calldatas} = gov.methods.getActions(proposalId).call();

Get Receipt

function getReceipt(uint proposalId, address voter) returns (Receipt memory)

Returns a proposal ballot receipt of a given voter.

Name

Type

proposalid

uint

ID of the proposal in which to get a voter's ballot receipt.

voter

address

Address of the account of a proposal voter.

Receipt

struct

A Receipt struct for the ballot of the voter address.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
Receipt ballot = gov.getReceipt(proposalId, voterAddress);

Web3

const proposalId = 11;
const voterAddress = '0x123...';
const result = await gov.methods.getReceipt(proposalId, voterAddress).call();
const { hasVoted, support, votes } = result;

State

function state(uint proposalId) returns (ProposalState)

Returns enum of the type ProposalState, possible types are; Pending, Active, Canceled, Defeated, Succeeded, Queued, Expired and Executed.

Name

Type

proposalid

uint

ID of the proposal.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
GovernorAlpha.ProposalState state = gov.state(123);

Web3

const proposalStates = ['Pending', 'Active', 'Canceled', 'Defeated', 'Succeeded', 'Queued', 'Expired', 'Executed'];
const proposalId = 123;
result = await gov.methods.state(proposalId).call();
const proposalState = proposalStates[result];const tx = gov.methods.castVote(proposalId, 0).send({ from: sender });

State-Changing Functions: Governor Alpha

Propose

function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) returns (uint)

Creates a proposal to create a market, issue a grant or change the protocol.

Proposals will be voted on by delegated voters. If there is sufficient support before the voting period ends, the proposal shall be automatically enacted. Enacted proposals are queued and executed in the Timelock contract.

The sender must hold more gPHRO than the current proposal threshold (proposalThreshold()) as of the immediate previous block. If the threshold is 2,000,000 gPHRO, the sender must have been delegated more than 1% of all gPHRO in order to create a proposal. The proposal can have up to 10 actions (based on proposalMaxOperations()).

Name

Type

targets

address

The ordered list of target addresses for calls to be made during proposal execution. This array must be the same length of all other array parameters in this function.

values

uint

The ordered list of values (i.e. msg.value) to be passed to the calls made during the proposal execution. This array must be the same length of all other array parameters in this function.

signatures

string

The ordered list of function signatures to be passed during proposal execution. This array must be the same length of all other array parameters in this function.

calldatas

bytes

The ordered list of data to be passed to each individual function call during proposal execution. This array must be the same length of all other array parameters in this function.

description

string

A human readable description of the proposal and the changes it will enact.

RETURN

uint

Returns the ID of the new proposal.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
uint proposalId = gov.propose(targets, values, signatures, calldatas, description);

Web3

const tx = gov.methods.propose(targets, values, signatures, calldatas, description).send({ from: sender });

Queue

function queue(uint proposalId)

After a proposal has succeeded, any address can call the queue method to move the proposal into the Timelock queue. A proposal can only be queued

Name

Type

proposalid

uint

ID of a given successful proposal.

RETURN

no

Reverts on error.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
gov.queue(proposalId);

Web3

const tx = gov.methods.queue(proposalId).send({ from: sender });

Execute

function execute(uint proposalId) payable

After the Timelock delay period, any account may invoke the execute method to apply the changes from the proposal to the target contracts. This will invoke each of the actions described in the proposal.

The execute function can be called by any Ethereum address.

This function is payable so the Timelock contract can invoke payable functions that were selected in the proposal.

Name

Type

proposalid

uint

ID of a given s

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
gov.execute(proposalId).value(999).gas(999)();

Web3

const tx = gov.methods.execute(proposalId).send({ from: sender, value: 1 });

Cancel

function queue(uint proposalId)

A proposal is eligible to be cancelled at any time prior to its execution, including while queued in the Timelock, using this function.

The cancel function can be called by the proposal creator, or any Ethereum address, if the proposal creator fails to maintain more delegated votes than the proposal threshold (e.g. 2,000,000).

Name

Type

proposalid

uint

ID of a proposal to cancel.

Solidity

GovernorAlpha gov = GovernorAlppha(0x123...); // contract address
gov.cancel(proposalId);

Web3

const tx = gov.methods.cancel(proposalId).send({ from: sender });

Cast Vote

function castVote(uint proposalId, bool support)

Cast a vote on a proposal. The account's voting weight is determined by its number of delegated votes at the time the proposal becomes active.

Name

Type

proposalid

uint

ID of a given successful proposal.

support

bool

A boolean of true for 'yes' and false for 'no' on the proposal vote.

RETURN

no

Reverts on error.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
gov.castVote(proposalId, 1);

Web3

const tx = gov.methods.castVote(proposalId, 0).send({ from: sender });

Cast Vote By Signature

function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s)

Cast a vote on a proposal. The account's voting weight is determined its number of delegated votes at the time the proposal became active. This method has the same purpose as Cast Vote, but instead enables offline signatures to participate in governance voting. For more details on how to create an offline signature, review EIP-712.

Name

Type

proposalid

uint

ID of a given successful proposal.

support

bool

A boolean of true for 'yes' and false for 'no' on the proposal vote.

expiry

uint

The time when the signature expires. A block timestamp in seconds since the UNIX epoch.

v

uint

The recovery byte of the signature.

r

bytes32

Half of the ECDSA signature pair.

s

bytes32

Half of the ECDSA signature pair.

Solidity

GovernorAlpha gov = GovernorAlpha(0x123...); // contract address
gov.castVoteBySig(proposalId, 0, v, r, s);

Web3

const tx = await gov.methods.castVoteBySig(proposalId, 1, v, r, s).send({});