Governance

This section is for developers and technical users. For a non-technical overview, see the Protocol Governance section of Aavenomics.

The LEND (and AAVE) token can be used in the protocol's decision-making process, ensuring that the protocol evolves and grows in a decentralised manner.

Overview

On a technical level, the main components of the Aave Genesis Governance are:

  • The AaveProtoGovernance contract, which handles most of the logic for voting.

  • The AssetVotingWeightProvider contract, which whitelists and sets voting weight for assets.

  • The AavePropositionPower contract, which controls permissions for protocol governance such as registering a new proposal.

  • The GovernanceParamsProvider contract, which stores the global protocol governance parameters such as the threshold of proposition power needed to register a new proposal.

Genesis Governance proposals have distinct phases:

  1. Creation: A proposal is created by a user with enough proposition power. In the early stages, this will be the Genesis team. The proposal includes code that will be executed on passing of the proposal.

  2. Voting: The proposal enters the 'Voting' phase, with a duration of _votingBlocksDuration.

    1. Votes are made by sending vote transactions to the AaveProtoGovernance contract using submitVoteByVoter().

  3. Validating: At the end of the _votingBlocksDuration, if the voting _threshold has been reached,

    the proposal is moved to the 'Validating' phase with a duration of _validatingBlocksDuration .

    1. If the _thresholdhas not been reached, then the proposal will remain in the 'Voting' phase until the _threshold is reached.

    2. During the 'Validating' phase, anyone can challenge (and cancel invalid) votes by calling the challengeVoters() method. Votes are considered invalid if their vote token balance is currently lower than the vote token balance at the time of voting.

    3. This process, going from 'Validating' and back to 'Voting' can happen a maximum number of _maxMovesToVotingAllowed, after which it is considered 'Expired' if it has not passed.

  4. Execution: At the end of _validatingBlocksDuration, the proposal is resolved and the status is changed to 'Executed'.

    1. If the votes _threshold has been reached then the execute() method of the proposal's _proposalExecutor is called, implementing/executing the governance proposal code.

    2. If the votes _threshold has not been reached, then no proposal code is executed.

Deployed Contracts

All contract source code can be found in the Github repository.

For an example of a Governance proposal payload, see the Genesis Proposal Payload and Genesis Migration repository.

Audits

The Governance contracts have been audited by Consensys Diligence.

Integrating AAVE voting

To perform AAVE voting and governance in your integration, the following steps should be followed:

1. Getting a list of proposals and associated details

You can fetch the list of proposal IDs a few ways :

  • Off-chain: use the emitted event from AaveProtoGovernance contract: ProposalCreated()

  • On-chain: use try...catch pattern to iterate through proposal IDs, starting at index 0

  • Via our GraphQL: query our subgraph to receive a list of proposals and their IDs

Once you have a list of the proposals, you can query for more proposal data:

2. Voting on proposals

Once you have the proposal ID, a vote can be made by simply submitting a transaction using submitVoteByVoter().

You can change the user's vote by calling submitVoteByVoter() again with the new vote, or cancel the vote with cancelVoteByVoter() and re-submitting.

There is also the possibility of submitting a vote by relayer if desired.

3. Getting the status of a proposal

Similar to what was mentioned above, you can retrieve associated proposal data such as current vote status and thresholds by calling getProposalBasicData() or by querying our subgraph.

Other useful methods includes getLimitBlockOfProposal(), getLeadingChoice(), getVoterData(), and getVotesData().

Relevant Methods

submitVoteByVoter()

Contract: AaveProtoGovernance

function submitVoteByVoter(uint256 _proposalId, uint256 _vote, IERC20 _asset)

Submits a vote by the caller.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

_vote

uint

A value indicating their vote (Abstain: 0, Yes: 1, No: 2).

_asset

address

The address of the asset used for voting.

The vote is only allowed if the _asset is whitelisted in the AssetVotingWeightProvider contract.

If the voter has already voted, their previous vote will be overridden.

cancelVoteByVoter()

Contract: AaveProtoGovernance

function cancelVoteByVoter(uint256 _proposalId)

Cancels a vote by the caller.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

challengeVoters()

Contract: AaveProtoGovernance

function challengeVoters(uint256 _proposalId, address[] calldata _voters)

During the 'Validating' phase, anyone can call this method to challenge and cancel invalid votes. This is to prevent double-voting attacks.

A vote is considered invalid when the voter's current balance of the voting asset is less than the balance of the.same asset at the time of casting their vote.

E.g. Alice has a balance of 100 LEND, votes on Proposal 1, and sends 50 LEND to an exchange before the end of the 'Validating' phase. Her vote would become invalid as her current balance is less than her balance at the time of making the vote.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

_voters

address[]

An array of voter addresses to challenge.

getLimitBlockOfProposal()

Contract: AaveProtoGovernance

function getLimitBlockOfProposal(uint256 _proposalId)

Gets the maximum block number that a proposal is potentially 'Resolvable'. If the current block number is greater than this value, then the proposal is 'Invalid'.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

Returns

Return Parameter

Type

Description

_limitBlockProposal

uint

The block number limit.

getLeadingChoice()

Contract: AaveProtoGovernance

function getLeadingChoice(uint256 _proposalId)

Gets the current leading choice in votes, i.e. the current majority of votes.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

Returns

Return Parameter

Type

Description

_leadingChoice

uint

The numeric reference of the leading choice (Abstain: 0, Yes: 1, No: 2).

getProposalBasicData()

Contract: AaveProtoGovernance

function getProposalBasicData(uint256 _proposalId)

Gets the basic data of a proposal.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

Returns

Return Parameter

Type

Description

_totalVotes

uint

The current total number of votes.

_threshold

uint

The threshold of votes required for a proposal to pass.

_maxMovesToVotingAllowed

uint

The number of times the proposal can move back to 'Voting' state.

_movesToVoting

uint

Current amount of times the proposal has been in the 'Voting' state.

_votingBlocksDuration

uint

The minimum number of blocks the proposal needs to be in 'Voting' before being changed to 'Validating'.

_validatingBlocksDuration

uint

The minimum number of blocks the proposal needs to be in 'Validating' before being changed to 'Executed'.

_currentStatusInitBlock

uint

Block number where the current status started.

_initProposalBlock

uint

Block number where the proposal was created.

_proposalStatus

uint

Status of the proposal.

_proposalExecutor

address

The smart contract address with the execute() payload.

_proposalType

bytes32

Hashed type of the proposal, e.g. keccak256(UPGRADE_ADDRESS_PROPOSAL).

getVoterData()

Contract: AaveProtoGovernance

function getVoterData(uint256 _proposalId, address _voterAddress)

Gets the voting data of a particular voter for a proposal ID.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

_voterAddress

address

The address of the voter.

Returns

Return Parameter

Type

Description

_vote

uint

The vote that was made (Abstain: 0, Yes: 1, No: 2).

_weight

uint

The weight of the voting asset used, referenced from AssetVotingWeightProvider contract.

_balance

uint

The balance of the _asset used at time of voting.

_nonce

uint

The nonce of the voter address to protect against vote replay attacks. It is increased by 1 on both voting and cancelling of a vote. If the user overrides a previous vote, the nonce is increased twice.

_asset

address

Address of the asset used to vote.

getVotesData()

Contract: AaveProtoGovernance

function getVotesData(uint256 _proposalId)

Gets the voting data, i.e. the cumulative votes of each choice, for a given proposal ID.

Parameter

Type

Description

_proposalId

uint

The ID of the governance proposal.

Returns

Return Parameter

Type

Description

_votes

uint[3]

The cumulative number of votes for each vote type. E.g. [1, 2, 3] translates to Abstain: 1, Yes: 2, No: 3.

getGovParamsProvider()

Contract: AaveProtoGovernance

function getGovParamsProvider()

Returns the address of the GovernanceParamsProvider contract.