IIGovernanceVotePower
#
Source | Inherits from IGovernanceVotePower
Internal interface for contracts delegating their governance vote power.
Events#
DelegateChanged
#
event DelegateChanged(
address delegator,
address fromDelegate,
address toDelegate
)
Emitted when an account starts delegating vote power or switches its delegation to another address.
The event is always emitted from a GovernanceVotePower
contract.
Parameters | Type | Description |
---|---|---|
delegator |
address |
Account delegating its vote power. |
fromDelegate |
address |
Account receiving the delegation before the change. Can be address(0) if there was no previous delegation. |
toDelegate |
address |
Account receiving the delegation after the change. Can be address(0) if delegator just undelegated all its vote power. |
DelegateVotesChanged
#
event DelegateVotesChanged(
address delegate,
uint256 previousBalance,
uint256 newBalance
)
Emitted when a delegate
's vote power changes, as a result of a new delegation
or a token transfer, for example.
The event is always emitted from a GovernanceVotePower
contract.
Parameters | Type | Description |
---|---|---|
delegate |
address |
The account receiving the changing delegated vote power. |
previousBalance |
uint256 |
Delegated vote power before the change. |
newBalance |
uint256 |
Delegated vote power after the change. |
Functions#
delegate
#
function delegate(
address _to
) external;
Delegates all governance vote power of msg.sender
to address _to
.
Parameters | Type | Description |
---|---|---|
_to |
address |
The address of the recipient. |
getCleanupBlockNumber
#
function getCleanupBlockNumber(
) external view returns (
uint256);
Get the current cleanup block number set with setCleanupBlockNumber
.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The currently set cleanup block number. |
getDelegateOfAt
#
function getDelegateOfAt(
address _who,
uint256 _blockNumber
) external view returns (
address);
Gets the address an account is delegating its governance vote power to, at a given block number.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address being queried. |
_blockNumber |
uint256 |
The block number at which to fetch the address. |
Returns | Type | Description |
---|---|---|
[0] | address |
Address where _who was delegating its governance vote power at block _blockNumber . |
getDelegateOfAtNow
#
function getDelegateOfAtNow(
address _who
) external view returns (
address);
Gets the address an account is delegating its governance vote power to, at the latest block number.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address being queried. |
Returns | Type | Description |
---|---|---|
[0] | address |
Address where _who is currently delegating its governance vote power. |
getVotes
#
function getVotes(
address _who
) external view returns (
uint256);
Gets the governance vote power of an address at the latest block, including all delegations made to it.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address being queried. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Governance vote power of account at the lastest block. |
ownerToken
#
function ownerToken(
) external view returns (
contract IVPToken);
Get the token that this governance vote power contract belongs to.
Returns | Type | Description |
---|---|---|
[0] | contract IVPToken |
The IVPToken interface owning this contract. |
pChainStakeMirror
#
function pChainStakeMirror(
) external view returns (
contract IPChainStakeMirror);
Get the stake mirror contract that this governance vote power contract belongs to.
Returns | Type | Description |
---|---|---|
[0] | contract IPChainStakeMirror |
The IPChainStakeMirror interface owning this contract. |
setCleanerContract
#
function setCleanerContract(
address _cleanerContract
) external;
Set the contract that is allowed to call history cleaning methods.
Parameters | Type | Description |
---|---|---|
_cleanerContract |
address |
Address of the cleanup contract. Usually this will be an instance of CleanupBlockNumberManager . |
setCleanupBlockNumber
#
function setCleanupBlockNumber(
uint256 _blockNumber
) external;
Set the cleanup block number.
Historic data for the blocks before cleanupBlockNumber
can be erased.
History before that block should never be used since it can be inconsistent.
In particular, cleanup block number must be lower than the current vote power block.
Parameters | Type | Description |
---|---|---|
_blockNumber |
uint256 |
The new cleanup block number. |
undelegate
#
function undelegate(
) external;
Undelegates all governance vote power of msg.sender
.
updateAtTokenTransfer
#
function updateAtTokenTransfer(
address _from,
address _to,
uint256 _fromBalance,
uint256 _toBalance,
uint256 _amount
) external;
Update governance vote power of all involved delegates after tokens are transferred.
This function MUST be called after each governance token transfer for the delegates to reflect the correct balance.
Parameters | Type | Description |
---|---|---|
_from |
address |
Source address of the transfer. |
_to |
address |
Destination address of the transfer. |
_fromBalance |
uint256 |
Ignored. |
_toBalance |
uint256 |
Ignored. |
_amount |
uint256 |
Amount being transferred. |
votePowerOfAt
#
function votePowerOfAt(
address _who,
uint256 _blockNumber
) external view returns (
uint256);
Gets the governance vote power of an address at a given block number, including all delegations made to it.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address being queried. |
_blockNumber |
uint256 |
The block number at which to fetch the vote power. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Governance vote power of _who at _blockNumber . |