VEGOVERNANCE API

Core

VotingEscrow

constructor() public

initialize(address _token, address _dao, address _clock, uint256 _initialMinDeposit) external

setCurve(address _curve) external

Sets the curve contract that calculates the voting power

setVoter(address _voter) external

Sets the voter contract that tracks votes

setQueue(address _queue) external

Sets the exit queue contract that manages withdrawal eligibility

setClock(address _clock) external

Sets the clock contract that manages epoch and voting periods

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.

pause() external

unpause() external

setMinDeposit(uint256 _minDeposit) external

isApprovedOrOwner(address _spender, uint256 _tokenId) → bool external

ownedTokens(address _owner) → uint256[] tokenIds public

Fetch all NFTs owned by an address by leveraging the ERC721Enumerable interface

votingPower(uint256 _tokenId) → uint256 public

votingPowerAt(uint256 _tokenId, uint256 _t) → uint256 public

totalVotingPower() → uint256 external

Currently unsupported

totalVotingPowerAt(uint256 _timestamp) → uint256 public

Currently unsupported

locked(uint256 _tokenId) → struct ILockedBalanceIncreasing.LockedBalance external

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.

createLock(uint256 _value) → uint256 external

Deposit _value tokens for msg.sender

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.

withdraw(uint256 _tokenId) external

Withdraws tokens from the contract

sweep() external

withdraw excess tokens from the contract - possibly by accident

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

SWEEPER_ROLE() → bytes32 public

Role required to withdraw underlying tokens from the contract

decimals() → uint8 public

Decimals of the voting power

minDeposit() → uint256 public

Minimum deposit amount

lastLockId() → uint256 public

Auto-incrementing ID for the most recently created lock, does not decrease on withdrawal

totalLocked() → uint256 public

Total supply of underlying tokens deposited in the contract

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

curve() → address public

Address of the voting Escrow Curve contract that will calculate the voting power

queue() → address public

Address of the contract that manages exit queue logic for withdrawals

clock() → address public

Address of the clock contract that manages epoch and voting periods

lockNFT() → address public

Address of the NFT contract that is the lock

ExitQueue

Modifiers
Events
IExitMinLockCooldownErrorsAndEvents
IExitQueueCooldownErrorsAndEvents
IExitQueueFeeErrorsAndEvents
Errors
IExitQueueCooldownErrorsAndEvents
IExitQueueFeeErrorsAndEvents

onlyEscrow() modifier

constructor() public

initialize(address _escrow, uint48 _cooldown, address _dao, uint256 _feePercent, address _clock, uint48 _minLock) external

setCooldown(uint48 _cooldown) external

The exit queue manager can set the cooldown period

_setCooldown(uint48 _cooldown) internal

setFeePercent(uint256 _feePercent) external

The exit queue manager can set the fee percent

_setFeePercent(uint256 _feePercent) internal

setMinLock(uint48 _minLock) external

The exit queue manager can set the minimum lock time

Min 1 second to prevent single block deposit-withdrawal attacks

_setMinLock(uint48 _minLock) internal

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.

calculateFee(uint256 _tokenId) → uint256 public

Calculate the exit fee for a given tokenId

canExit(uint256 _tokenId) → bool public

If the admin chages the cooldown, this will affect all ticket holders. We may not want this.

ticketHolder(uint256 _tokenId) → address external

queue(uint256 _tokenId) → struct ITicket.Ticket external

tokenId ⇒ Ticket

timeToMinLock(uint256 _tokenId) → uint48 public

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

QUEUE_ADMIN_ROLE() → bytes32 public

role required to manage the exit queue

WITHDRAW_ROLE() → bytes32 public

role required to withdraw tokens from the escrow contract

feePercent() → uint256 public

the fee percent charged on withdrawals

escrow() → address public

address of the escrow contract

clock() → address public

clock contract for epoch duration

cooldown() → uint48 public

time in seconds between exit and withdrawal

minLock() → uint48 public

minimum time from the original lock date before one can enter the queue

mapping(uint256 => struct ITicket.Ticket) _queue internal

tokenId ⇒ Ticket

QuadraticIncreasingEscrow

Events
IWarmupEvents
Errors
IEscrowCurveErrorsAndEvents

constructor() public

initialize(address _escrow, address _dao, uint48 _warmupPeriod, address _clock) external

_getQuadraticCoeff(uint256 amount) → int256 internal

_getLinearCoeff(uint256 amount) → int256 internal

_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

_getBias(uint256 timeElapsed, int256[3] coefficients) → uint256 internal

_maxTime() → uint256 internal

previewMaxBias(uint256 amount) → uint256 external

setWarmupPeriod(uint48 _warmupPeriod) external

isWarm(uint256 tokenId) → bool public

Returns whether the NFT is warm

_isWarm(struct IEscrowCurveTokenStorage.TokenPoint _point) → bool public

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

CURVE_ADMIN_ROLE() → bytes32 public

Administrator role for the contract

escrow() → address public

The VotingEscrow contract address

clock() → address public

The Clock contract address

tokenPointIntervals() → mapping(uint256 => uint256) public

tokenId ⇒ point epoch: incremented on a per-tokenId basis

warmupPeriod() → uint48 public

The warmup period for the curve

OnlyEscrow() error

mapping(uint256 => struct IEscrowCurveTokenStorage.TokenPoint[1000000000]) _tokenPointHistory internal

tokenId ⇒ tokenPointIntervals ⇒ TokenPoint The Array is fixed so we can write to it in the future This implementation means that very short intervals may be challenging

SimpleGaugeVoter

Modifiers

whenVotingActive() modifier

constructor() public

initialize(address _dao, address _escrow, bool _startPaused, address _clock) external

pause() external

unpause() external

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.

_vote(uint256 _tokenId, struct IGaugeVote.GaugeVote[] _votes) internal

reset(uint256 _tokenId) external

Called by users to reset voting state. Required when withdrawing or transferring veNFT.

_reset(uint256 _tokenId) internal

gaugeExists(address _gauge) → bool public

isActive(address _gauge) → bool public

createGauge(address _gauge, string _metadataURI) → address gauge external

deactivateGauge(address _gauge) external

activateGauge(address _gauge) external

updateGaugeMetadata(address _gauge, string _metadataURI) external

epochId() → uint256 public

autogenerated epoch id based on elapsed time

votingActive() → bool public

whether voting is active in the current epoch

epochStart() → uint256 external

timestamp of the start of the next epoch

epochVoteStart() → uint256 external

timestamp of the start of the next voting period

epochVoteEnd() → uint256 external

timestamp of the end of the current voting period

getGauge(address _gauge) → struct IGauge.Gauge external

getAllGauges() → address[] external

isVoting(uint256 _tokenId) → bool public

Can be called to check if a token is currently voting

votes(uint256 _tokenId, address _gauge) → uint256 external

gaugesVotedFor(uint256 _tokenId) → address[] external

usedVotingPower(uint256 _tokenId) → uint256 external

GAUGE_ADMIN_ROLE() → bytes32 public

The Gauge admin can can create and manage voting gauges for token holders

escrow() → address public

Address of the voting escrow contract that will track voting power

clock() → address public

Clock contract for epoch duration

totalVotingPowerCast() → uint256 public

The total votes that have accumulated in this contract

gaugeList() → address[] public

enumerable list of all gauges that can be voted on

gauges() → mapping(address => struct IGauge.Gauge) public

address ⇒ gauge data

gaugeVotes() → mapping(address => uint256) public

gauge ⇒ total votes (global)

mapping(uint256 => struct IGaugeVote.TokenVoteData) tokenVoteData internal

tokenId ⇒ tokenVoteData

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.

encodeSetupData(struct ISimpleGaugeVoterSetupParams _params) → bytes external

encodeSetupData(bool isPaused, string veTokenName, string veTokenSymbol, address token, uint48 cooldown, uint48 warmup, uint256 feePercent, uint48 minLock, uint256 minDeposit) → bytes external

Simple utility for external applications create the encoded setup data.

EXECUTE_PERMISSION_ID() → bytes32 public

The identifier of the EXECUTE_PERMISSION permission.

WrongHelpersArrayLength(uint256 length) error

Thrown if passed helpers array is of wrong length.

address voterBase internal

implementation of the gaugevoting plugin

address curveBase internal

implementation of the escrow voting curve

address queueBase internal

implementation of the exit queue

address escrowBase internal

implementation of the escrow locker

address clockBase internal

implementation of the clock

address nftBase internal

implementation of the escrow NFT

Lock

Modifiers
Events

onlyEscrow() modifier

supportsInterface(bytes4 _interfaceId) → bool public

constructor() public

initialize(address _escrow, string _name, string _symbol, address _dao) external

setWhitelisted(address _account, bool _isWhitelisted) external

Transfers disabled by default, only whitelisted addresses can receive transfers

enableTransfers() external

Enable transfers to any address without whitelisting

_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

isApprovedOrOwner(address _spender, uint256 _tokenId) → bool external

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

WHITELIST_ANY_ADDRESS() → address public

enables transfers without whitelisting

LOCK_ADMIN_ROLE() → bytes32 public

role to upgrade this contract

escrow() → address public

Address of the escrow contract that holds underyling assets

whitelisted() → mapping(address => bool) public

Whitelisted contracts that are allowed to transfer

Clock

Events

constructor() public

initialize(address _dao) external

epochDuration() → uint256 external

checkpointInterval() → uint256 external

voteDuration() → uint256 external

voteWindowBuffer() → uint256 external

currentEpoch() → uint256 external

resolveEpoch(uint256 timestamp) → uint256 public

elapsedInEpoch() → uint256 external

resolveElapsedInEpoch(uint256 timestamp) → uint256 public

epochStartsIn() → uint256 external

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

epochStartTs() → uint256 external

resolveEpochStartTs(uint256 timestamp) → uint256 public

Timestamp of the start of the next epoch (absolute)

votingActive() → bool external

resolveVotingActive(uint256 timestamp) → bool public

epochVoteStartsIn() → uint256 external

resolveEpochVoteStartsIn(uint256 timestamp) → uint256 public

Number of seconds until voting starts.

If voting is active, returns 0.

epochVoteStartTs() → uint256 external

resolveEpochVoteStartTs(uint256 timestamp) → uint256 public

Timestamp of the start of the next voting period (absolute)

epochVoteEndsIn() → uint256 external

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

epochVoteEndTs() → uint256 external

resolveEpochVoteEndTs(uint256 timestamp) → uint256 public

Timestamp of the end of the current voting period (absolute)

epochNextCheckpointIn() → uint256 external

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

epochNextCheckpointTs() → uint256 external

resolveEpochNextCheckpointTs(uint256 timestamp) → uint256 public

Timestamp of the next deposit interval (absolute)

_authorizeUpgrade(address) internal

implementation() → address external

CLOCK_ADMIN_ROLE() → bytes32 public

uint256 EPOCH_DURATION internal constant

Epoch encompasses a voting and non-voting period

uint256 CHECKPOINT_INTERVAL internal constant

Checkpoint interval is the time between each voting checkpoint

uint256 VOTE_DURATION internal constant

Voting duration is the time during which votes can be cast

uint256 VOTE_WINDOW_BUFFER internal constant

Opens and closes the voting window slightly early to avoid timing attacks