Skip to content

WNat#

Source | Inherits from VPToken, IWNat

Wrapped native token.

This contract converts native tokens into WNAT (wrapped native) tokens and vice versa. WNAT tokens are a one-to-one ERC20 representation of native tokens, which are minted and burned as needed by this contract.

The wrapped versions of the native FLR and SGB tokens are called WFLR and WSGB respectively.

Besides the standard ERC20 operations, this contract supports FTSO delegation and governance vote delegation.

Code attribution: WETH9.

Events#

Approval#

Defined in IERC20 (Source).

event Approval(
    address owner,
    address spender,
    uint256 value
)

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

CreatedTotalSupplyCache#

Defined in CheckPointable (Docs, Source).

event CreatedTotalSupplyCache(
    uint256 _blockNumber
)

Emitted when a total supply cache entry is created. Allows history cleaners to track total supply cache cleanup opportunities off-chain.

Deposit#

Defined in WNat (Docs, Source).

event Deposit(
    address dst,
    uint256 amount
)

Emitted when tokens have been wrapped.

Parameters Type Description
dst address The account that received the wrapped tokens.
amount uint256 The amount that was wrapped.

GovernanceCallTimelocked#

Defined in GovernedBase (Docs, Source).

event GovernanceCallTimelocked(
    bytes4 selector,
    uint256 allowedAfterTimestamp,
    bytes encodedCall
)

Emitted when a new governance call has been recorded and is now waiting for the time lock to expire.

GovernanceInitialised#

Defined in GovernedBase (Docs, Source).

event GovernanceInitialised(
    address initialGovernance
)

Emitted when the governance address is initialized. This address will be used until production mode is entered (see GovernedProductionModeEntered). At that point the governance address is taken from GovernanceSettings.

GovernedProductionModeEntered#

Defined in GovernedBase (Docs, Source).

event GovernedProductionModeEntered(
    address governanceSettings
)

Emitted when governance is enabled and the governance address cannot be changed anymore (only through a network fork).

TimelockedGovernanceCallCanceled#

Defined in GovernedBase (Docs, Source).

event TimelockedGovernanceCallCanceled(
    bytes4 selector,
    uint256 timestamp
)

Emitted when a timelocked governance call is canceled before execution.

TimelockedGovernanceCallExecuted#

Defined in GovernedBase (Docs, Source).

event TimelockedGovernanceCallExecuted(
    bytes4 selector,
    uint256 timestamp
)

Emitted when a timelocked governance call is executed.

Transfer#

Defined in IERC20 (Source).

event Transfer(
    address from,
    address to,
    uint256 value
)

Emitted when value tokens are moved from one account (from) to another (to).

Note that value may be zero.

VotePowerContractChanged#

Defined in VPToken (Docs, Source).

event VotePowerContractChanged(
    uint256 _contractType,
    address _oldContractAddress,
    address _newContractAddress
)

Emitted when one of the vote power contracts is changed.

It is used to track the history of VPToken -> VPContract / GovernanceVotePower associations (e.g. by external cleaners).

Parameters Type Description
_contractType uint256 0 = Read VPContract, 1 = Write VPContract, 2 = Governance vote power.
_oldContractAddress address Contract address before change.
_newContractAddress address Contract address after change.

Withdrawal#

Defined in WNat (Docs, Source).

event Withdrawal(
    address src,
    uint256 amount
)

Emitted when tokens have been unwrapped.

Parameters Type Description
src address The account that received the unwrapped tokens.
amount uint256 The amount that was unwrapped.

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.

balanceHistoryCleanup#

Defined in CheckPointable (Docs, Source).

function balanceHistoryCleanup(
    address _owner,
    uint256 _count
) external returns (
    uint256);

Delete balance 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 the number of checkpoints deleted

balanceOf#

Defined in IERC20 (Source).

function balanceOf(
    address account
) external view returns (
    uint256);

Returns the amount of tokens owned by account.

balanceOfAt#

Defined in VPToken (Docs, Source).

function balanceOfAt(
    address _owner,
    uint256 _blockNumber
) public 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

batchDelegate#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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.

cancelGovernanceCall#

Defined in GovernedBase (Docs, Source).

function cancelGovernanceCall(
    bytes4 _selector
) external;

Cancel a timelocked governance call before it has been executed.

Only governance can call this method.

Parameters Type Description
_selector bytes4 The method selector.

cleanupBlockNumber#

Defined in VPToken (Docs, Source).

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.

constructor#

Defined in WNat (Docs, Source).

constructor(
    address _governance,
    string _name,
    string _symbol
) public;

Construct an ERC20 token.

decimals#

Defined in VPToken (Docs, Source).

function decimals(
) public 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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

function delegatesOf(
    address _owner
) 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
_owner address
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#

Defined in VPToken (Docs, Source).

function delegatesOfAt(
    address _owner,
    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
_owner address
_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#

Defined in VPToken (Docs, Source).

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).

deposit#

Defined in WNat (Docs, Source).

function deposit(
) public payable;

Deposits native tokens and mints the same amount of WNAT tokens, which are added to the msg.sender's balance. This operation is commonly known as "wrapping".

Emits a Deposit event.

depositTo#

Defined in WNat (Docs, Source).

function depositTo(
    address _recipient
) external payable;

Deposits native tokens and mints the same amount of WNAT tokens, which are added to _recipient's balance. This operation is commonly known as "wrapping".

This is equivalent to using deposit followed by transfer.

Emits a Deposit event.

Parameters Type Description
_recipient address The address to receive the minted WNAT.

executeGovernanceCall#

Defined in GovernedBase (Docs, Source).

function executeGovernanceCall(
    bytes4 _selector
) external;

Execute the timelocked governance calls once the timelock period expires.

Only executor can call this method.

Parameters Type Description
_selector bytes4 The method selector (only one timelocked call per method is stored).

governance#

Defined in GovernedBase (Docs, Source).

function governance(
) public view returns (
    address);

Returns the current effective governance address.

governanceVotePower#

Defined in VPToken (Docs, Source).

function governanceVotePower(
) external view returns (
    contract IGovernanceVotePower);

When set, allows token owners to participate in governance voting and delegate governance vote power.

name#

Defined in VPToken (Docs, Source).

function name(
) public view returns (
    string);

Returns the name of the token.

Should be compatible with ERC20 method.

readVotePowerContract#

Defined in VPToken (Docs, Source).

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.

receive#

Defined in WNat (Docs, Source).

receive(
) external payable;

A proxy for the deposit method.

revokeDelegationAt#

Defined in VPToken (Docs, Source).

function revokeDelegationAt(
    address _who,
    uint256 _blockNumber
) public;

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

function setCleanupBlockNumberManager(
    address _cleanupBlockNumberManager
) external;

Set the contract that is allowed to set cleanupBlockNumber. Usually this will be an instance of CleanupBlockNumberManager.

setGovernanceVotePower#

Defined in VPToken (Docs, Source).

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.

setReadVpContract#

Defined in VPToken (Docs, Source).

function setReadVpContract(
    contract IIVPContract _vpContract
) external;

Call from governance to set read VpContract on token, e.g. vpToken.setReadVpContract(new VPContract(vpToken)).

Read VPContract must be set before any of the VPToken delegation or vote power reading methods are called, otherwise they will revert.

NOTE: If readVpContract differs from writeVpContract all reads will be "frozen" and will not reflect changes (not even revokes; they may or may not reflect balance transfers).

Parameters Type Description
_vpContract contract IIVPContract Read vote power contract to be used by this token.

setWriteVpContract#

Defined in VPToken (Docs, Source).

function setWriteVpContract(
    contract IIVPContract _vpContract
) external;

Call from governance to set write VpContract on token, e.g. vpToken.setWriteVpContract(new VPContract(vpToken)).

Write VPContract must be set before any of the VPToken delegation modifying methods are called, otherwise they will revert.

Parameters Type Description
_vpContract contract IIVPContract Write vote power contract to be used by this token.

switchToProductionMode#

Defined in GovernedBase (Docs, Source).

function switchToProductionMode(
) external;

Enter the production mode after all the initial governance settings have been set. This enables timelocks and the governance can be obtained afterward by calling governanceSettings.getGovernanceAddress(). Emits GovernedProductionModeEntered.

symbol#

Defined in VPToken (Docs, Source).

function symbol(
) public view returns (
    string);

Returns the symbol of the token, usually a shorter version of the name.

Should be compatible with ERC20 method.

totalSupply#

Defined in IERC20 (Source).

function totalSupply(
) external view returns (
    uint256);

Returns the amount of tokens in existence.

totalSupplyAt#

Defined in VPToken (Docs, Source).

function totalSupplyAt(
    uint256 _blockNumber
) public view returns (
    uint256);

Total amount of tokens at a specific _blockNumber.

Parameters Type Description
_blockNumber uint256 The block number when the _totalSupply is queried
Returns Type Description
[0] uint256

totalSupplyCacheCleanup#

Defined in CheckPointable (Docs, Source).

function totalSupplyCacheCleanup(
    uint256 _blockNumber
) external returns (
    uint256);

Delete total supply 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
_blockNumber uint256 the block number for which total supply value was cached
Returns Type Description
[0] uint256 the number of cache entries deleted (always 0 or 1)

totalSupplyHistoryCleanup#

Defined in CheckPointable (Docs, Source).

function totalSupplyHistoryCleanup(
    uint256 _count
) external returns (
    uint256);

Delete total supply 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
_count uint256 maximum number of checkpoints to delete
Returns Type Description
[0] uint256 the number of checkpoints deleted

totalVotePower#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

function totalVotePowerAtCached(
    uint256 _blockNumber
) public 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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

function undelegateAllExplicit(
    address[] _delegateAddresses
) external returns (
    uint256 _remainingDelegation);

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
_remainingDelegation uint256 The amount still delegated (in case the list of delegates was incomplete).

undelegatedVotePowerOf#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

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#

Defined in VPToken (Docs, Source).

function votePowerOfAtCached(
    address _owner,
    uint256 _blockNumber
) public 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#

Defined in VPToken (Docs, Source).

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.

withdraw#

Defined in WNat (Docs, Source).

function withdraw(
    uint256 _amount
) external;

Burns _amount of WNAT tokens from msg.sender's WNAT balance and transfers the same amount of native tokens to msg.sender. This operation is commonly known as "unwrapping".

Reverts if _amount is higher than msg.sender's WNAT balance.

Emits a Withdrawal event.

Parameters Type Description
_amount uint256 The amount to withdraw.

withdrawFrom#

Defined in WNat (Docs, Source).

function withdrawFrom(
    address _owner,
    uint256 _amount
) external;

Burns _amount of WNAT tokens from _owner's WNAT balance and transfers the same amount of native tokens to msg.sender. This operation is commonly known as "unwrapping".

msg.sender must have been authorized to withdraw from _owner's account through ERC-20's approve mechanism.

Reverts if _amount is higher than _owners's WNAT balance or than msg.sender's allowance over _owner's tokens.

Emits a Withdrawal event.

Parameters Type Description
_owner address The address containing the tokens to withdraw.
_amount uint256 The amount to withdraw.

writeVotePowerContract#

Defined in VPToken (Docs, Source).

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.


Last update: 2024-03-01