Delegatable
#
Source | Inherits from IVPContractEvents
Delegatable
ERC20 behavior.
Adds delegation capabilities to tokens. This contract orchestrates interaction between managing a delegation and the vote power allocations that result.
Enums#
Events#
CreatedVotePowerCache
#
event CreatedVotePowerCache(
address _owner,
uint256 _blockNumber
)
Emitted when a vote power cache entry is created. Allows history cleaners to track vote power cache cleanup opportunities off-chain.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address whose vote power has just been cached. |
_blockNumber |
uint256 |
The block number at which the vote power has been cached. |
Delegate
#
event Delegate(
address from,
address to,
uint256 priorVotePower,
uint256 newVotePower
)
Emitted when the amount of vote power delegated from one account to another changes.
Note: This event is always emitted from VPToken
's writeVotePowerContract
.
Parameters | Type | Description |
---|---|---|
from |
address |
The account that has changed the amount of vote power it is delegating. |
to |
address |
The account whose received vote power has changed. |
priorVotePower |
uint256 |
The vote power originally delegated. |
newVotePower |
uint256 |
The new vote power that triggered this event. It can be 0 if the delegation is completely canceled. |
Revoke
#
event Revoke(
address delegator,
address delegatee,
uint256 votePower,
uint256 blockNumber
)
Emitted when an account revokes its vote power delegation to another account for a single current or past block (typically the current vote block).
Note: This event is always emitted from VPToken
's writeVotePowerContract
or readVotePowerContract
.
See revokeDelegationAt
in IVPToken
.
Parameters | Type | Description |
---|---|---|
delegator |
address |
The account that revoked the delegation. |
delegatee |
address |
The account that has been revoked. |
votePower |
uint256 |
The revoked vote power. |
blockNumber |
uint256 |
The block number at which the delegation has been revoked. |
Functions#
explicitDelegationHistoryCleanup
#
function explicitDelegationHistoryCleanup(
address _from,
address _to,
uint256 _count
) external returns (
uint256);
Delete explicit delegation checkpoints that expired (i.e. are before cleanupBlockNumber
).
Method can only be called from the cleanerContract
(which may be a proxy to external cleaners).
Parameters | Type | Description |
---|---|---|
_from |
address |
Delegator address. |
_to |
address |
Delegatee address. |
_count |
uint256 |
Maximum number of checkpoints to delete. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Number of checkpoints deleted. |
percentageDelegationHistoryCleanup
#
function percentageDelegationHistoryCleanup(
address _owner,
uint256 _count
) external returns (
uint256);
Delete percentage delegation checkpoints that expired (i.e. are before cleanupBlockNumber
).
Method can only be called from the cleanerContract
(which may be a proxy to external cleaners).
Parameters | Type | Description |
---|---|---|
_owner |
address |
Balance owner account address. |
_count |
uint256 |
Maximum number of checkpoints to delete. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Number of deleted checkpoints. |
revocationCleanup
#
function revocationCleanup(
address _from,
address _to,
uint256 _blockNumber
) external returns (
uint256);
Delete revocation entry that expired (i.e. is before cleanupBlockNumber
).
Method can only be called from the cleanerContract
(which may be a proxy to external cleaners).
Parameters | Type | Description |
---|---|---|
_from |
address |
Delegator address. |
_to |
address |
Delegatee address. |
_blockNumber |
uint256 |
Block number for which total supply value was cached. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Number of revocation entries deleted (always 0 or 1). |
votePowerCacheCleanup
#
function votePowerCacheCleanup(
address _owner,
uint256 _blockNumber
) external returns (
uint256);
Delete vote power cache entry that expired (i.e. is before cleanupBlockNumber
).
Method can only be called from the cleanerContract
(which may be a proxy to external cleaners).
Parameters | Type | Description |
---|---|---|
_owner |
address |
Vote power owner account address. |
_blockNumber |
uint256 |
Block number for which total supply value was cached. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Number of deleted cache entries (always 0 or 1). |
votePowerHistoryCleanup
#
function votePowerHistoryCleanup(
address _owner,
uint256 _count
) external returns (
uint256);
Delete vote power checkpoints that expired (i.e. are before cleanupBlockNumber
).
Method can only be called from the cleanerContract
(which may be a proxy to external cleaners).
Parameters | Type | Description |
---|---|---|
_owner |
address |
Vote power owner account address. |
_count |
uint256 |
Maximum number of checkpoints to delete. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Number of deleted checkpoints. |
Modifiers#
notBeforeCleanupBlock
#
modifier notBeforeCleanupBlock( uint256 _blockNumber)
Reading from history is not allowed before cleanupBlockNumber
, since data before that
might have been deleted and is thus unreliable.
Parameters | Type | Description |
---|---|---|
_blockNumber |
uint256 |
The block number being checked for validity. |
onlyCleaner
#
modifier onlyCleaner()
History cleaning methods can be called only from cleanerContract
.