VEGOVERNANCE API
Core
VotingEscrow
setLockNFT(address _nft)
external
Sets the NFT contract that is the lock
By default this can only be set once due to the high risk of changing the lock and having the ability to steal user funds.
ownedTokens(address _owner) → uint256[] tokenIds
public
Fetch all NFTs owned by an address by leveraging the ERC721Enumerable interface
votingPowerForAccount(address _account) → uint256 accountVotingPower
external
We cannot do historic voting power at this time because we don’t current track histories of token transfers.
isVoting(uint256 _tokenId) → bool
public
Checks if the NFT is currently voting. We require the user to reset their votes if so.
createLockFor(uint256 _value, address _to) → uint256
external
Creates a lock on behalf of someone else. Restricted by default.
_createLockFor(uint256 _value, address _to) → uint256
internal
Deposit _value
tokens for _to
starting at next deposit interval
resetVotesAndBeginWithdrawal(uint256 _tokenId)
external
Resets the votes and begins the withdrawal process for a given tokenId
Convenience function, the user must have authorized this contract to act on their behalf.
beginWithdrawal(uint256 _tokenId)
public
Enters a tokenId into the withdrawal queue by transferring to this contract and creating a ticket.
The user must not have active votes in the voter contract.
sweepNFT(uint256 _tokenId, address _to)
external
the sweeper can send NFTs mistakenly sent to the contract to a designated address
Cannot sweep NFTs that are in the exit queue for obvious reasons
implementation() → address
public
Returns the address of the implementation contract in the [proxy storage slot](https://eips.ethereum.org/EIPS/eip-1967) slot the [UUPS proxy](https://eips.ethereum.org/EIPS/eip-1822) is pointing to.
_authorizeUpgrade(address)
internal
Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).
ESCROW_ADMIN_ROLE() → bytes32
public
Role required to manage the Escrow curve, this typically will be the DAO
PAUSER_ROLE() → bytes32
public
Role required to pause the contract - can be given to emergency contracts
lastLockId() → uint256
public
Auto-incrementing ID for the most recently created lock, does not decrease on withdrawal
token() → address
public
Address of the underying ERC20 token.
Only tokens with 18 decimals and no transfer fees are supported
voter() → address
public
Address of the gauge voting contract.
We need to ensure votes are not left in this contract before allowing positing changes
ExitQueue
initialize(address _escrow, uint48 _cooldown, address _dao, uint256 _feePercent, address _clock, uint48 _minLock)
external
setMinLock(uint48 _minLock)
external
The exit queue manager can set the minimum lock time
Min 1 second to prevent single block deposit-withdrawal attacks
withdraw(uint256 _amount)
external
withdraw staked tokens sent as part of fee collection to the caller
The caller must be authorized to withdraw by the DAO
queueExit(uint256 _tokenId, address _ticketHolder)
external
queue an exit for a given tokenId, granting the ticket to the passed holder
we don’t check that the ticket holder is the caller this is because the escrow contract is the only one that can queue an exit and we leave that logic to the escrow contract
nextExitDate() → uint256
public
Returns the next exit date for a ticket
The next exit date is the later of the cooldown expiry and the next checkpoint
exit(uint256 _tokenId) → uint256 fee
external
Exits the queue for that tokenID.
The holder is not checked. This is left up to the escrow contract to manage.
canExit(uint256 _tokenId) → bool
public
If the admin chages the cooldown, this will affect all ticket holders. We may not want this.
implementation() → address
public
Returns the address of the implementation contract in the [proxy storage slot](https://eips.ethereum.org/EIPS/eip-1967) slot the [UUPS proxy](https://eips.ethereum.org/EIPS/eip-1822) is pointing to.
_authorizeUpgrade(address)
internal
Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).
QuadraticIncreasingEscrow
_getConstantCoeff(uint256 amount) → int256
public
In this case, the constant term is 1 so we just case the amount
_getCoefficients(uint256 amount) → int256[3]
public
The coefficients are returned in the order [constant, linear, quadratic]
getCoefficients(uint256 amount) → int256[3]
public
The coefficients are returned in the order [constant, linear, quadratic] and are converted to regular 256-bit signed integers instead of their fixed-point representation
getBias(uint256 timeElapsed, uint256 amount) → uint256
public
Returns the bias for the given time elapsed and amount, up to the maximum time
tokenPointHistory(uint256 _tokenId, uint256 _tokenInterval) → struct IEscrowCurveTokenStorage.TokenPoint
external
Returns the TokenPoint at the passed interval
_getPastTokenPointInterval(uint256 _tokenId, uint256 _timestamp) → uint256
internal
Binary search to get the token point interval for a token id at or prior to a given timestamp Once we have the point, we can apply the bias calculation to get the voting power.
If a token point does not exist prior to the timestamp, this will return 0.
votingPowerAt(uint256 _tokenId, uint256 _t) → uint256
external
Get the current voting power for _tokenId
Adheres to the ERC20 balanceOf
interface for Aragon compatibility
Fetches last token point prior to a certain timestamp, then walks forward to timestamp.
supplyAt(uint256) → uint256
external
[NOT IMPLEMENTED] Calculate total voting power at some point in the past
This function will be implemented in a future version of the contract
checkpoint(uint256 _tokenId, struct ILockedBalanceIncreasing.LockedBalance _oldLocked, struct ILockedBalanceIncreasing.LockedBalance _newLocked)
external
A checkpoint can be called by the VotingEscrow contract to snapshot the user’s voting power
_checkpoint(uint256 _tokenId, struct ILockedBalanceIncreasing.LockedBalance, struct ILockedBalanceIncreasing.LockedBalance _newLocked)
internal
Record gper-user data to checkpoints. Used by VotingEscrow system.
Curve finance style but just for users at this stage
implementation() → address
public
Returns the address of the implementation contract in the [proxy storage slot](https://eips.ethereum.org/EIPS/eip-1967) slot the [UUPS proxy](https://eips.ethereum.org/EIPS/eip-1822) is pointing to.
_authorizeUpgrade(address)
internal
Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).
SimpleGaugeVoter
voteMultiple(uint256[] _tokenIds, struct IGaugeVote.GaugeVote[] _votes)
external
extrememly simple for loop. We don’t need reentrancy checks in this implementation because the plugin doesn’t do anything other than signal.
vote(uint256 _tokenId, struct IGaugeVote.GaugeVote[] _votes)
public
Called by users to vote for pools. Votes distributed proportionally based on weights.
reset(uint256 _tokenId)
external
Called by users to reset voting state. Required when withdrawing or transferring veNFT.
SimpleGaugeVoterSetup
constructor(address _voterBase, address _curveBase, address _queueBase, address _escrowBase, address _clockBase, address _nftBase)
public
Deploys the setup by binding the implementation contracts required during installation.
implementation() → address
external
Returns the plugin implementation address.
The implementation can be instantiated via the new
keyword, cloned via the minimal clones pattern (see [ERC-1167](https://eips.ethereum.org/EIPS/eip-1167)), or proxied via the UUPS pattern (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).
prepareInstallation(address _dao, bytes _data) → address plugin, struct IPluginSetup.PreparedSetupData preparedSetupData
external
Prepares the installation of a plugin.
You need to set the helpers on the plugin as a post install action.
prepareUninstallation(address _dao, struct IPluginSetup.SetupPayload _payload) → struct PermissionLib.MultiTargetPermission[] permissions
external
Prepares the uninstallation of a plugin.
getPermissions(address _dao, address _plugin, address _curve, address _queue, address _escrow, address _clock, address _nft, enum PermissionLib.Operation _grantOrRevoke) → struct PermissionLib.MultiTargetPermission[]
public
Returns the permissions required for the plugin install and uninstall.
Lock
setWhitelisted(address _account, bool _isWhitelisted)
external
Transfers disabled by default, only whitelisted addresses can receive transfers
_transfer(address _from, address _to, uint256 _tokenId)
internal
Override the transfer to check if the recipient is whitelisted This avoids needing to check for mint/burn but is less idomatic than beforeTokenTransfer
mint(address _to, uint256 _tokenId)
external
Minting and burning functions that can only be called by the escrow contract
Safe mint ensures contract addresses are ERC721 Receiver contracts
burn(uint256 _tokenId)
external
Minting and burning functions that can only be called by the escrow contract
implementation() → address
public
Returns the address of the implementation contract in the [proxy storage slot](https://eips.ethereum.org/EIPS/eip-1967) slot the [UUPS proxy](https://eips.ethereum.org/EIPS/eip-1822) is pointing to.
_authorizeUpgrade(address)
internal
Internal method authorizing the upgrade of the contract via the [upgradeability mechanism for UUPS proxies](https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable) (see [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822)).
Clock
resolveEpochStartsIn(uint256 timestamp) → uint256
public
Number of seconds until the start of the next epoch (relative)
If exactly at the start of the epoch, returns 0
resolveEpochStartTs(uint256 timestamp) → uint256
public
Timestamp of the start of the next epoch (absolute)
resolveEpochVoteStartsIn(uint256 timestamp) → uint256
public
Number of seconds until voting starts.
If voting is active, returns 0.
resolveEpochVoteStartTs(uint256 timestamp) → uint256
public
Timestamp of the start of the next voting period (absolute)
resolveEpochVoteEndsIn(uint256 timestamp) → uint256
public
Number of seconds until the end of the current voting period (relative)
If we are outside the voting period, returns 0
resolveEpochVoteEndTs(uint256 timestamp) → uint256
public
Timestamp of the end of the current voting period (absolute)
resolveEpochNextCheckpointIn(uint256 timestamp) → uint256
public
Number of seconds until the next checkpoint interval (relative)
If exactly at the start of the checkpoint interval, returns 0
resolveEpochNextCheckpointTs(uint256 timestamp) → uint256
public
Timestamp of the next deposit interval (absolute)