// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;/**
* @title Errors library
* @author BGD Labs
* @notice Defines the error messages emitted by the different contracts of the Aave Governance V3
*/libraryErrors{
stringpublicconstant VOTING_PORTALS_COUNT_NOT_0 ='1'; // to be able to rescue voting portals count must be 0stringpublicconstant AT_LEAST_ONE_PAYLOAD ='2'; // to create a proposal, it must have at least one payloadstringpublicconstant VOTING_PORTAL_NOT_APPROVED ='3'; // the voting portal used to vote on proposal must be approvedstringpublicconstant PROPOSITION_POWER_IS_TOO_LOW ='4'; // proposition power of proposal creator must be equal or higher than the specified threshold for the access levelstringpublicconstant PROPOSAL_NOT_IN_CREATED_STATE ='5'; // proposal should be in the CREATED statestringpublicconstant PROPOSAL_NOT_IN_ACTIVE_STATE ='6'; // proposal must be in an ACTIVE statestringpublicconstant PROPOSAL_NOT_IN_QUEUED_STATE ='7'; // proposal must be in a QUEUED statestringpublicconstant VOTING_START_COOLDOWN_PERIOD_NOT_PASSED ='8'; // to activate a proposal vote, the cool down delay must passstringpublicconstant CALLER_NOT_A_VALID_VOTING_PORTAL ='9'; // only an allowed voting portal can queue a proposalstringpublicconstant QUEUE_COOLDOWN_PERIOD_NOT_PASSED ='10'; // to execute a proposal a cooldown delay must passstringpublicconstant PROPOSAL_NOT_IN_THE_CORRECT_STATE ='11'; // proposal must be created but not executed yet to be able to be canceledstringpublicconstant CALLER_NOT_GOVERNANCE ='12'; // caller must be governancestringpublicconstant VOTER_ALREADY_VOTED_ON_PROPOSAL ='13'; // voter can only vote once per proposal using voting portalstringpublicconstant WRONG_MESSAGE_ORIGIN ='14'; // received message must come from registered source address, chain id, CrossChainControllerstringpublicconstant NO_VOTING_ASSETS ='15'; // Strategy must have voting assetsstringpublicconstant PROPOSAL_VOTE_ALREADY_CREATED ='16'; // vote on proposal can only be created oncestringpublicconstant INVALID_SIGNATURE ='17'; // submitted signature is not validstringpublicconstant PROPOSAL_VOTE_NOT_FINISHED ='18'; // proposal vote must be finishedstringpublicconstant PROPOSAL_VOTE_NOT_IN_ACTIVE_STATE ='19'; // proposal vote must be in active statestringpublicconstant PROPOSAL_VOTE_ALREADY_EXISTS ='20'; // proposal vote already existsstringpublicconstant VOTE_ONCE_FOR_ASSET ='21'; // an asset can only be used once per votestringpublicconstant USER_BALANCE_DOES_NOT_EXISTS ='22'; // to vote an user must have balance in the token the user is voting withstringpublicconstant USER_VOTING_BALANCE_IS_ZERO ='23'; // to vote an user must have some balance between all the tokens selected for votingstringpublicconstant MISSING_AAVE_ROOTS ='24'; // must have AAVE roots registered to use strategystringpublicconstant MISSING_STK_AAVE_ROOTS ='25'; // must have stkAAVE roots registered to use strategystringpublicconstant MISSING_STK_AAVE_SLASHING_EXCHANGE_RATE ='26'; // must have stkAAVE slashing exchange rate registered to use strategystringpublicconstant UNPROCESSED_STORAGE_ROOT ='27'; // root must be registered beforehandstringpublicconstant NOT_ENOUGH_MSG_VALUE ='28'; // method was not called with enough value to execute the callstringpublicconstant FAILED_ACTION_EXECUTION ='29'; // action failed to executestringpublicconstant SHOULD_BE_AT_LEAST_ONE_EXECUTOR ='30'; // at least one executor is neededstringpublicconstant INVALID_EMPTY_TARGETS ='31'; // target of the payload execution must not be emptystringpublicconstant EXECUTOR_WAS_NOT_SPECIFIED_FOR_REQUESTED_ACCESS_LEVEL ='32'; // payload executor must be registered for the specified payload access levelstringpublicconstant PAYLOAD_NOT_IN_QUEUED_STATE ='33'; // payload must be en the queued statestringpublicconstant TIMELOCK_NOT_FINISHED ='34'; // delay has not passed before execution can be calledstringpublicconstant PAYLOAD_NOT_IN_THE_CORRECT_STATE ='35'; // payload must be created but not executed yet to be able to be canceledstringpublicconstant PAYLOAD_NOT_IN_CREATED_STATE ='36'; // payload must be in the created statestringpublicconstant MISSING_A_AAVE_ROOTS ='37'; // must have aAAVE roots registered to use strategystringpublicconstant MISSING_PROPOSAL_BLOCK_HASH ='38'; // block hash for this proposal was not bridged beforestringpublicconstant PROPOSAL_VOTE_CONFIGURATION_ALREADY_BRIDGED ='39'; // configuration for this proposal bridged alreadystringpublicconstant INVALID_VOTING_PORTAL_ADDRESS ='40'; // voting portal address can't be 0x0stringpublicconstant INVALID_POWER_STRATEGY ='41'; // 0x0 is not valid as the power strategystringpublicconstant INVALID_EXECUTOR_ADDRESS ='42'; // executor address can't be 0x0stringpublicconstant EXECUTOR_ALREADY_SET_IN_DIFFERENT_LEVEL ='43'; // executor address already being used as executor of a different levelstringpublicconstant INVALID_VOTING_DURATION ='44'; // voting duration can not be bigger than the time it takes to execute a proposalstringpublicconstant VOTING_DURATION_NOT_PASSED ='45'; // at least votingDuration should have passed since voting started for a proposal to be queuedstringpublicconstant INVALID_PROPOSAL_ACCESS_LEVEL ='46'; // the bridged proposal access level does not correspond with the maximum access level required by the payloadstringpublicconstant PAYLOAD_NOT_CREATED_BEFORE_PROPOSAL ='47'; // payload must be created before proposalstringpublicconstant INVALID_CROSS_CHAIN_CONTROLLER_ADDRESS ='48';
stringpublicconstant INVALID_MESSAGE_ORIGINATOR_ADDRESS ='49';
stringpublicconstant INVALID_ORIGIN_CHAIN_ID ='50';
stringpublicconstant INVALID_ACTION_TARGET ='51';
stringpublicconstant INVALID_ACTION_ACCESS_LEVEL ='52';
stringpublicconstant INVALID_EXECUTOR_ACCESS_LEVEL ='53';
stringpublicconstant INVALID_VOTING_PORTAL_CROSS_CHAIN_CONTROLLER ='54';
stringpublicconstant INVALID_VOTING_PORTAL_VOTING_MACHINE ='55';
stringpublicconstant INVALID_VOTING_PORTAL_GOVERNANCE ='56';
stringpublicconstant INVALID_VOTING_MACHINE_CHAIN_ID ='57';
stringpublicconstant G_INVALID_CROSS_CHAIN_CONTROLLER_ADDRESS ='58';
stringpublicconstant G_INVALID_IPFS_HASH ='59';
stringpublicconstant G_INVALID_PAYLOAD_ACCESS_LEVEL ='60';
stringpublicconstant G_INVALID_PAYLOADS_CONTROLLER ='61';
stringpublicconstant G_INVALID_PAYLOAD_CHAIN ='62';
stringpublicconstant POWER_STRATEGY_HAS_NO_TOKENS ='63'; // power strategy should at least havestringpublicconstant INVALID_VOTING_CONFIG_ACCESS_LEVEL ='64';
stringpublicconstant VOTING_DURATION_TOO_SMALL ='65';
stringpublicconstant NO_BRIDGED_VOTING_ASSETS ='66';
stringpublicconstant INVALID_VOTER ='67';
stringpublicconstant INVALID_DATA_WAREHOUSE ='68';
stringpublicconstant INVALID_VOTING_MACHINE_CROSS_CHAIN_CONTROLLER ='69';
stringpublicconstant INVALID_L1_VOTING_PORTAL ='70';
stringpublicconstant INVALID_VOTING_PORTAL_CHAIN_ID ='71';
stringpublicconstant INVALID_VOTING_STRATEGY ='72';
stringpublicconstant INVALID_VOTE_CONFIGURATION_BLOCKHASH ='73';
stringpublicconstant INVALID_VOTE_CONFIGURATION_VOTING_DURATION ='74';
stringpublicconstant INVALID_GAS_LIMIT ='75';
stringpublicconstant INVALID_VOTING_CONFIGS ='76'; // a lvl2 voting configuration must be sent to initializerstringpublicconstant INVALID_EXECUTOR_DELAY ='77';
stringpublicconstant REPEATED_STRATEGY_ASSET ='78';
stringpublicconstant EMPTY_ASSET_STORAGE_SLOTS ='79';
stringpublicconstant REPEATED_STRATEGY_ASSET_SLOT ='80';
stringpublicconstant INVALID_EXECUTION_TARGET ='81';
stringpublicconstant MISSING_VOTING_CONFIGURATIONS ='82'; // voting configurations for lvl1 and lvl2 must be included on initializationstringpublicconstant INVALID_PROPOSITION_POWER ='83';
stringpublicconstant INVALID_YES_THRESHOLD ='84';
stringpublicconstant INVALID_YES_NO_DIFFERENTIAL ='85';
stringpublicconstant ETH_TRANSFER_FAILED ='86';
stringpublicconstant INVALID_INITIAL_VOTING_CONFIGS ='87'; // initial voting configurations can not be of the same levelstringpublicconstant INVALID_VOTING_PORTAL_ADDRESS_IN_VOTING_MACHINE ='88';
stringpublicconstant INVALID_VOTING_PORTAL_OWNER ='89';
stringpublicconstant CANCELLATION_FEE_REDEEM_FAILED ='90'; // cancellation fee was not able to be redeemedstringpublicconstant INVALID_CANCELLATION_FEE_COLLECTOR ='91'; // collector can not be address 0stringpublicconstant INVALID_CANCELLATION_FEE_SENT ='92'; // cancellation fee sent does not match the needed amountstringpublicconstant CANCELLATION_FEE_ALREADY_REDEEMED ='93'; // cancellation fee already redeemedstringpublicconstant INVALID_STATE_TO_REDEEM_CANCELLATION_FEE ='94'; // proposal state is not a valid state to redeem cancellation feestringpublicconstant MISSING_REPRESENTATION_ROOTS ='95'; // to represent a voter the representation roots need to be registeredstringpublicconstant CALLER_IS_NOT_VOTER_REPRESENTATIVE ='96'; // to represent a voter, caller must be the stored representativestringpublicconstant VM_INVALID_GOVERNANCE_ADDRESS ='97'; // governance address can not be 0stringpublicconstant ALL_DELEGATION_ACTIONS_FAILED ='98'; // all meta delegation actions failed on MetaDelegateHelper
}
Contract Source Code
File 2 of 4: IGovernancePowerDelegationToken.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;interfaceIGovernancePowerDelegationToken{
enumGovernancePowerType {
VOTING,
PROPOSITION
}
/**
* @dev emitted when a user delegates to another
* @param delegator the user which delegated governance power
* @param delegatee the delegatee
* @param delegationType the type of delegation (VOTING, PROPOSITION)
**/eventDelegateChanged(addressindexed delegator,
addressindexed delegatee,
GovernancePowerType delegationType
);
// @dev we removed DelegatedPowerChanged event because to reconstruct the full state of the system,// is enough to have Transfer and DelegateChanged TODO: document it/**
* @dev delegates the specific power to a delegatee
* @param delegatee the user which delegated power will change
* @param delegationType the type of delegation (VOTING, PROPOSITION)
**/functiondelegateByType(address delegatee, GovernancePowerType delegationType) external;
/**
* @dev delegates all the governance powers to a specific user
* @param delegatee the user to which the powers will be delegated
**/functiondelegate(address delegatee) external;
/**
* @dev returns the delegatee of an user
* @param delegator the address of the delegator
* @param delegationType the type of delegation (VOTING, PROPOSITION)
* @return address of the specified delegatee
**/functiongetDelegateeByType(address delegator, GovernancePowerType delegationType)
externalviewreturns (address);
/**
* @dev returns delegates of an user
* @param delegator the address of the delegator
* @return a tuple of addresses the VOTING and PROPOSITION delegatee
**/functiongetDelegates(address delegator)
externalviewreturns (address, address);
/**
* @dev returns the current voting or proposition power of a user.
* @param user the user
* @param delegationType the type of delegation (VOTING, PROPOSITION)
* @return the current voting or proposition power of a user
**/functiongetPowerCurrent(address user, GovernancePowerType delegationType)
externalviewreturns (uint256);
/**
* @dev returns the current voting or proposition power of a user.
* @param user the user
* @return the current voting and proposition power of a user
**/functiongetPowersCurrent(address user)
externalviewreturns (uint256, uint256);
/**
* @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
* @param delegator the owner of the funds
* @param delegatee the user to who owner delegates his governance power
* @param delegationType the type of governance power delegation (VOTING, PROPOSITION)
* @param deadline the deadline timestamp, type(uint256).max for no deadline
* @param v signature param
* @param s signature param
* @param r signature param
*/functionmetaDelegateByType(address delegator,
address delegatee,
GovernancePowerType delegationType,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev implements the permit function as for https://github.com/ethereum/EIPs/blob/8a34d644aacf0f9f8f00815307fd7dd5da07655f/EIPS/eip-2612.md
* @param delegator the owner of the funds
* @param delegatee the user to who delegator delegates his voting and proposition governance power
* @param deadline the deadline timestamp, type(uint256).max for no deadline
* @param v signature param
* @param s signature param
* @param r signature param
*/functionmetaDelegate(address delegator,
address delegatee,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
}
Contract Source Code
File 3 of 4: IMetaDelegateHelper.sol
// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import {IGovernancePowerDelegationToken} from'aave-token-v3/interfaces/IGovernancePowerDelegationToken.sol';
/**
* @title IMetaDelegateHelper
* @author BGD Labs
* @notice Interface containing the methods for the batch governance power delegation across multiple voting assets
*/interfaceIMetaDelegateHelper{
enumDelegationType {
VOTING,
PROPOSITION,
ALL
}
/**
* @notice an object including parameters for the delegation change
* @param underlyingAsset the asset the governance power of which delegator wants to delegate
* @param delegationType the type of governance power delegation (VOTING, PROPOSITION, ALL)
* @param delegator the owner of the funds
* @param delegatee the user to who owner delegates his governance power
* @param deadline the deadline timestamp, type(uint256).max for no deadline
* @param v signature param
* @param s signature param
* @param r signature param
*/structMetaDelegateParams {
IGovernancePowerDelegationToken underlyingAsset;
DelegationType delegationType;
address delegator;
address delegatee;
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
/**
* @notice method for the batch upgrade governance power delegation across multiple voting assets with signatures
* @param delegateParams an array with signatures with the user and assets to interact with
*/functionbatchMetaDelegate(MetaDelegateParams[] calldata delegateParams)
external;
}