Governance Subgraph

Subgraph of protocol Governance system (Proposals, Voters, Votes, etc.)

Proposal

Proposal schema:

type Proposal @entity {
  id: String!
  proposer: Bytes!
  targets: [Bytes!]!
  values: [BigInt!]!
  signatures: [String!]!
  callDatas: [Bytes!]!
  startBlock: BigInt!
  endBlock: BigInt!
  description: String!
  state: ProposalState!
  eta: BigInt!
  forVotes: BigInt!
  againstVotes: BigInt!
  createdBlockNumber: BigInt!
  createdBlockTimestamp: BigInt!
  createdTransactionHash: Bytes!
  queuedBlockNumber: BigInt
  queuedBlockTimestamp: BigInt
  queuedTransactionHash: Bytes
  executedBlockNumber: BigInt
  executedBlockTimestamp: BigInt
  executedTransactionHash: Bytes
  canceledBlockNumber: BigInt
  canceledBlockTimestamp: BigInt
  canceledTransactionHash: Bytes
}

enum ProposalState {
  pending
  canceled
  queued
  executed
}
Field
Type
Description

id

String! (required string)

Unique string id (e.g. 1, 15, 20)

proposer

Bytes! (required string)

Address of the proposer

targets

[Bytes!]! (required string array)

Array of contract addresses which will be interacted due to proposal execution

values

[BigInt!]! (required string array)

Array of values which will be placed into contract method due to proposal execution

signatures

[String!]! (required string array)

Array of signatures for contract method due to proposal execution

callDatas

[Bytes!]! (required string array)

Array of call data for contract method due to proposal execution

startBlock

BigInt! (required string)

Number of the block when proposal will be active

endBlock

BigInt! (required string)

Number of the block when proposal will be ended

description

String! (required string)

Description of the proposal

state

ProposalState! (required string)

Four main states of the proposal, other states you can compute by this state and start block timestamp or end block timestamp

eta

BigInt! (required string)

ETA of the proposal

forVotes

BigInt! (required string)

Sum of votes for

againstVotes

BigInt! (required string)

Sum of votes against

createdBlockNumber

BigInt! (required string)

Number of the block when proposal was created

createdBlockTimestamp

BigInt! (required string)

Timestamp of the block when proposal was created

createdTransactionHash

Bytes! (required string)

Hash of the transaction with proposal creation event

queuedBlockNumber

BigInt! (required string)

Number of the block when proposal was queued

queuedBlockTimestamp

BigInt! (required string)

Timestamp of the block when proposal was queued

queuedTransactionHash

Bytes! (required string)

Hash of the transaction with proposal queue event

executedBlockNumber

BigInt! (required string)

Number of the block when proposal was executed

executedBlockTimestamp

BigInt! (required string)

Timestamp of the block when proposal was executed

executedTransactionHash

Bytes! (required string)

Hash of the transaction with proposal execution event

canceledBlockNumber

BigInt! (required string)

Number of the block when proposal was canceled

canceledBlockTimestamp

BigInt! (required string)

Timestamp of the block when proposal was canceled

canceledTransactionHash

Bytes! (required string)

Hash of the transaction with proposal cancel event

Example of Proposal querying:

{
  proposals {
    id
    proposer
    targets
    values
    signatures
    callDatas
    startBlock
    endBlock
    description
    state
    eta
    forVotes
    againstVotes
    createdBlockNumber
    createdBlockTimestamp
    createdTransactionHash
    queuedBlockNumber
    queuedBlockTimestamp
    queuedTransactionHash
    executedBlockNumber
    executedBlockTimestamp
    executedTransactionHash
    canceledBlockNumber
    canceledBlockTimestamp
    canceledTransactionHash
  }
}

Proposal vote

ProposalVote schema:

type ProposalVote @entity(immutable: true) {
  id: Bytes!
  proposal: Proposal!
  address: Bytes!
  support: Boolean!
  votes: BigInt!
  blockNumber: BigInt!
  blockTimestamp: BigInt!
  transactionHash: Bytes!
}
Field
Type
Description

id

Bytes! (required string)

Unique id for vote

proposal

Proposal! (required Proposal)

Voted for or against proposal

address

Bytes! (required string)

Address of the voters

support

Boolean! (required boolean)

If true - vote for If false - vote against

votes

BigInt! (required string)

Number of votes in receipt

blockNumber

BigInt! (required string)

Number of the block when vote was created

blockTimestamp

BigInt! (required string)

Timestamp of the block when vote was created

transactionHash

Bytes! (required string)

Hash of the transaction with event when vote was created

Example of ProposalVote querying:

{
  proposalVotes {
    id
    proposal {
      id
    }
    address
    support
    votes
    blockNumber
    blockTimestamp
    transactionHash
  }
}

Proposal count

Used to get total count of proposals

ProposalCount schema:

type ProposalCount @entity {
  id: String!
  count: BigInt!
}
Field
Type
Description

id

String! (required string)

System used id is "0"

count

BigInt! (required string)

Total count of proposals

Example of ProposalCount querying:

{
  proposalCounts(where: { id: "0" }) {
    id
    count
  }
}

Last updated