IIVPToken
#
Source | Inherits from IVPToken, IICleanable
Vote power token internal interface.
Functions#
allowance
#
Defined in IERC20
(Source).
function allowance(
address owner,
address spender
) external view returns (
uint256);
Returns the remaining number of tokens that spender
will be
allowed to spend on behalf of owner
through transferFrom
. This is
zero by default.
This value changes when approve
or transferFrom
are called.
approve
#
Defined in IERC20
(Source).
function approve(
address spender,
uint256 amount
) external returns (
bool);
Sets amount
as the allowance
of spender
over the caller's tokens.
Returns a boolean value indicating whether the operation succeeded.
IMPORTANT: Beware that changing an allowance
with this method brings the risk
that someone may use both the old and the new allowance
by unfortunate
transaction ordering. One possible solution to mitigate this race
condition is to first reduce the spender's allowance
to 0 and set the
desired value afterwards:
https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
Emits an Approval
event.
balanceOf
#
Defined in IERC20
(Source).
function balanceOf(
address account
) external view returns (
uint256);
Returns the amount of tokens owned by account
.
balanceOfAt
#
function balanceOfAt(
address _owner,
uint256 _blockNumber
) external view returns (
uint256);
Queries the token balance of _owner
at a specific _blockNumber
.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address from which the balance will be retrieved. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The balance at _blockNumber . |
batchDelegate
#
function batchDelegate(
address[] _delegatees,
uint256[] _bips
) external;
Undelegate all percentage delegations from the sender and then delegate
corresponding
_bips
percentage of voting power from the sender to each member of the _delegatees
array.
Parameters | Type | Description |
---|---|---|
_delegatees |
address[] |
The addresses of the new recipients. |
_bips |
uint256[] |
The percentages of voting power to be delegated expressed in basis points (1/100 of one percent). The sum of all _bips values must be at most 10000 (100%). |
batchVotePowerOfAt
#
function batchVotePowerOfAt(
address[] _owners,
uint256 _blockNumber
) external view returns (
uint256[]);
Return the vote power for several addresses.
Parameters | Type | Description |
---|---|---|
_owners |
address[] |
The list of addresses to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256[] |
Array of vote power for each queried address. |
cleanupBlockNumber
#
function cleanupBlockNumber(
) external view returns (
uint256);
Get the current cleanup block number set with setCleanupBlockNumber
.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The currently set cleanup block number. |
decimals
#
function decimals(
) external view returns (
uint8);
Returns the number of decimals
used to get its user representation.
For example, if decimals
equals 2, a balance of 505 tokens should
be displayed to a user as 5.05 (505 / 102).
Tokens usually opt for a value of 18, imitating the relationship between Ether and wei. This is the default value returned by this function, unless it's overridden.
NOTE: This information is only used for display purposes: it in
no way affects any of the arithmetic of the contract, including
balanceOf
and transfer
.
Should be compatible with ERC20 method.
delegate
#
function delegate(
address _to,
uint256 _bips
) external;
Delegate voting power to account _to
from msg.sender
, by percentage.
Parameters | Type | Description |
---|---|---|
_to |
address |
The address of the recipient. |
_bips |
uint256 |
The percentage of voting power to be delegated expressed in basis points (1/100 of one percent). Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations). |
delegateExplicit
#
function delegateExplicit(
address _to,
uint256 _amount
) external;
Explicitly delegate
_amount
voting power to account _to
from msg.sender
.
Compare with delegate
which delegates by percentage.
Parameters | Type | Description |
---|---|---|
_to |
address |
The address of the recipient. |
_amount |
uint256 |
An explicit vote power amount to be delegated. Not cumulative: every call resets the delegation value (and a value of 0 revokes all previous delegations). |
delegatesOf
#
function delegatesOf(
address _who
) external view returns (
address[] _delegateAddresses,
uint256[] _bips,
uint256 _count,
uint256 _delegationMode);
Get the list of addresses to which _who
is delegating, and their percentages.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address to query. |
Returns | Type | Description |
---|---|---|
_delegateAddresses |
address[] |
Positional array of addresses being delegated to. |
_bips |
uint256[] |
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array. |
_count |
uint256 |
The number of delegates. |
_delegationMode |
uint256 |
Delegation mode: 0 = NOT SET, 1 = PERCENTAGE, 2 = AMOUNT (i.e. explicit). |
delegatesOfAt
#
function delegatesOfAt(
address _who,
uint256 _blockNumber
) external view returns (
address[] _delegateAddresses,
uint256[] _bips,
uint256 _count,
uint256 _delegationMode);
Get the list of addresses to which _who
is delegating, and their percentages, at the given block.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
_delegateAddresses |
address[] |
Positional array of addresses being delegated to. |
_bips |
uint256[] |
Positional array of delegation percents specified in basis points (1/100 of 1 percent). Each one matches the address in the same position in the _delegateAddresses array. |
_count |
uint256 |
The number of delegates. |
_delegationMode |
uint256 |
Delegation mode: 0 = NOT SET, 1 = PERCENTAGE, 2 = AMOUNT (i.e. explicit). |
delegationModeOf
#
function delegationModeOf(
address _who
) external view returns (
uint256);
Get the delegation mode for account '_who'. This mode determines whether vote power is allocated by percentage or by explicit amount. Once the delegation mode is set, it can never be changed, even if all delegations are removed.
Parameters | Type | Description |
---|---|---|
_who |
address |
The address to get delegation mode. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Delegation mode: 0 = NOT SET, 1 = PERCENTAGE, 2 = AMOUNT (i.e. explicit). |
governanceVotePower
#
function governanceVotePower(
) external view returns (
contract IGovernanceVotePower);
When set, allows token owners to participate in governance voting and delegating governance vote power.
name
#
function name(
) external view returns (
string);
Returns the name
of the token.
Should be compatible with ERC20 method.
readVotePowerContract
#
function readVotePowerContract(
) external view returns (
contract IVPContractEvents);
Returns VPContract
event interface used for read-only operations (view methods).
The only non-view method that might be called on it is revokeDelegationAt
.
readVotePowerContract
is almost always equal to writeVotePowerContract
except during an upgrade from one VPContract
to a new version (which should happen
rarely or never and will be announced beforehand).
Do not call any methods on VPContract
directly.
State changing methods are forbidden from direct calls.
All methods are exposed via VPToken
.
This is the reason that this method returns IVPContractEvents
.
Use it only for listening to events and revoking.
revokeDelegationAt
#
function revokeDelegationAt(
address _who,
uint256 _blockNumber
) external;
Revoke all delegation from sender to _who
at given block.
Only affects the reads via votePowerOfAtCached()
in the block _blockNumber
.
Block _blockNumber
must be in the past.
This method should be used only to prevent rogue delegate
voting in the current voting block.
To stop delegating use delegate
/ delegateExplicit
with value of 0 or undelegateAll
/ undelegateAllExplicit
.
Parameters | Type | Description |
---|---|---|
_who |
address |
Address of the delegatee. |
_blockNumber |
uint256 |
The block number at which to revoke delegation.. |
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. |
setCleanupBlockNumberManager
#
function setCleanupBlockNumberManager(
address _cleanupBlockNumberManager
) external;
Set the contract that is allowed to set cleanupBlockNumber
.
Usually this will be an instance of CleanupBlockNumberManager
.
setGovernanceVotePower
#
function setGovernanceVotePower(
contract IIGovernanceVotePower _governanceVotePower
) external;
Sets new governance vote power contract that allows token owners to participate in governance voting
and delegate
governance vote power.
symbol
#
totalSupply
#
Defined in IERC20
(Source).
function totalSupply(
) external view returns (
uint256);
Returns the amount of tokens in existence.
totalSupplyAt
#
function totalSupplyAt(
uint256 _blockNumber
) external view returns (
uint256);
Total amount of tokens held by all accounts at a specific block number.
Parameters | Type | Description |
---|---|---|
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The total amount of tokens at _blockNumber . |
totalVotePower
#
function totalVotePower(
) external view returns (
uint256);
Get the current total vote power.
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The current total vote power (sum of all accounts' vote power). |
totalVotePowerAt
#
function totalVotePowerAt(
uint256 _blockNumber
) external view returns (
uint256);
Get the total vote power at block _blockNumber
.
Parameters | Type | Description |
---|---|---|
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The total vote power at the queried block (sum of all accounts' vote powers). |
totalVotePowerAtCached
#
function totalVotePowerAtCached(
uint256 _blockNumber
) external returns (
uint256);
Get the total vote power at block _blockNumber
using cache.
It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
Can only be used if _blockNumber
is in the past, otherwise reverts.
Parameters | Type | Description |
---|---|---|
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The total vote power at the queried block (sum of all accounts' vote powers). |
transfer
#
Defined in IERC20
(Source).
function transfer(
address recipient,
uint256 amount
) external returns (
bool);
Moves amount
tokens from the caller's account to recipient
.
Returns a boolean value indicating whether the operation succeeded.
Emits a Transfer
event.
transferFrom
#
Defined in IERC20
(Source).
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (
bool);
Moves amount
tokens from sender
to recipient
using the
allowance
mechanism. amount
is then deducted from the caller's
allowance
.
Returns a boolean value indicating whether the operation succeeded.
Emits a Transfer
event.
undelegateAll
#
function undelegateAll(
) external;
Undelegate all voting power of msg.sender
. This effectively revokes all previous delegations.
Can only be used with percentage delegation.
Does not reset delegation mode back to NOT SET.
undelegateAllExplicit
#
function undelegateAllExplicit(
address[] _delegateAddresses
) external returns (
uint256);
Undelegate all explicit vote power by amount of msg.sender
.
Can only be used with explicit delegation.
Does not reset delegation mode back to NOT SET.
Parameters | Type | Description |
---|---|---|
_delegateAddresses |
address[] |
Explicit delegation does not store delegatees' addresses, so the caller must supply them. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The amount still delegated (in case the list of delegates was incomplete). |
undelegatedVotePowerOf
#
function undelegatedVotePowerOf(
address _owner
) external view returns (
uint256);
Compute the current undelegated vote power of the _owner
account.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The unallocated vote power of _owner . |
undelegatedVotePowerOfAt
#
function undelegatedVotePowerOfAt(
address _owner,
uint256 _blockNumber
) external view returns (
uint256);
Get the undelegated vote power of the _owner
account at a given block number.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The unallocated vote power of _owner . |
votePowerFromTo
#
function votePowerFromTo(
address _from,
address _to
) external view returns (
uint256);
Get current delegated vote power from delegator _from
to delegatee _to
.
Parameters | Type | Description |
---|---|---|
_from |
address |
Address of delegator. |
_to |
address |
Address of delegatee. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
votePower The delegated vote power. |
votePowerFromToAt
#
function votePowerFromToAt(
address _from,
address _to,
uint256 _blockNumber
) external view returns (
uint256);
Get delegated vote power from delegator _from
to delegatee _to
at _blockNumber
.
Parameters | Type | Description |
---|---|---|
_from |
address |
Address of delegator. |
_to |
address |
Address of delegatee. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
The delegated vote power. |
votePowerOf
#
function votePowerOf(
address _owner
) external view returns (
uint256);
Get the current vote power of _owner
.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Current vote power of _owner . |
votePowerOfAt
#
function votePowerOfAt(
address _owner,
uint256 _blockNumber
) external view returns (
uint256);
Get the vote power of _owner
at block _blockNumber
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Vote power of _owner at block number _blockNumber . |
votePowerOfAtCached
#
function votePowerOfAtCached(
address _owner,
uint256 _blockNumber
) external returns (
uint256);
Get the vote power of _owner
at block _blockNumber
using cache.
It tries to read the cached value and if it is not found, reads the actual value and stores it in the cache.
Can only be used if _blockNumber
is in the past, otherwise reverts.
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Vote power of _owner at _blockNumber . |
votePowerOfAtIgnoringRevocation
#
function votePowerOfAtIgnoringRevocation(
address _owner,
uint256 _blockNumber
) external view returns (
uint256);
Get the vote power of _owner
at block _blockNumber
, ignoring revocation information (and cache).
Parameters | Type | Description |
---|---|---|
_owner |
address |
The address to query. |
_blockNumber |
uint256 |
The block number to query. |
Returns | Type | Description |
---|---|---|
[0] | uint256 |
Vote power of _owner at block number _blockNumber . Result doesn't change if vote power is revoked. |
writeVotePowerContract
#
function writeVotePowerContract(
) external view returns (
contract IVPContractEvents);
Returns VPContract
event interface used for state-changing operations (non-view methods).
The only non-view method that might be called on it is revokeDelegationAt
.
writeVotePowerContract
is almost always equal to readVotePowerContract
,
except during upgrade from one VPContract
to a new version (which should happen
rarely or never and will be announced beforehand).
In the case of an upgrade, writeVotePowerContract
is replaced first to establish delegations.
After some period (e.g., after a reward epoch ends), readVotePowerContract
is set equal to it.
Do not call any methods on VPContract
directly.
State changing methods are forbidden from direct calls.
All are exposed via VPToken
.
This is the reason that this method returns IVPContractEvents
Use it only for listening to events, delegating, and revoking.