Amplify
Launch AppGithub
  • Introduction
    • Amplify Overview
    • Concepts
      • Networks
      • DApps
      • Network Investors
      • LPs & Traders
    • Getting Started
      • Networks
      • DApps
      • Investors
  • Developers
    • Smart Contracts
      • VoteEscrowDistribution
      • Voter
      • VoteEscrow
      • Factories
        • Factory
        • IncentivesManagerFactory
        • VoterFactories
        • VoteEscrowFactory
        • GaugeFactory
          • BaseGaugeFactory
        • BribeFactory
          • BaseBribeFactory
      • Bribe
      • Gauge
      • IncentivesManager
    • Deployments
      • Arbitrum Sepolia
  • Resources
    • Brand Assets
    • Bug Bounty
    • Security & Audits
    • Whitelisting
  • Terms of Service
    • Privacy Policy
    • Terms of Use
Powered by GitBook
On this page
  • Description:
  • Constructor
  • setIncentivesManager
  • transferOwnership
  • reset
  • poke
  • vote
  • createGauge
  • attachTokenToGauge
  • emitDeposit
  • detachTokenFromGauge
  • emitWithdraw
  • length
  • notifyRewardAmount
  • updateFor
  • updateForRange
  • updateAll
  • updateGauge
  • claimRewards
  • claimBribes
  • claimFees
  • distributeFees
  • distribute (single gauge)
  • distro / distribute (no args)
  • distribute (range)
  • distribute (gauge array)
  1. Developers
  2. Smart Contracts

Voter

Description:

The Voter contract serves as the central hub for users to allocate their voting power (derived from locked tokens in a VotingEscrow contract, represented by NFTs) towards different liquidity pool gauges. Users vote on which pools should receive token emissions (rewards). This contract tracks votes, calculates total weights for each pool, interacts with gauge and bribe contracts, and manages the distribution of the base reward token to the gauges based on vote weights. It also provides functions for users to claim external bribes and fees associated with their votes.


Constructor

constructor(address __ve, address  _gauges, address _bribes, address _reward_token)

Description:

Initializes the Voter contract upon deployment. It sets the addresses of the core dependencies: the VotingEscrow contract (__ve), the GaugeFactory (_gauges), the BribeFactory (_bribes), and the base reward token (_reward_token) that will be distributed. It also sets the deployer as the initial owner of the contract.

Input Parameters:

Name
Type
Description

__ve

address

The address of the VotingEscrow contract managing voting power NFTs.

_gauges

address

The address of the GaugeFactory used to create new gauges.

_bribes

address

The address of the BribeFactory used to create bribe contracts.

_reward_token

address

The address of the ERC20 token used for base reward distributions.


setIncentivesManager

function setIncentivesManager(address _incentivesManager) external onlyOwner

Description:

Allows the owner to set the address of an IncentivesManager contract. This manager contract is likely used for coordinating reward distribution periods or other related logic, as seen in the distribute(address _gauge) function.

Input Parameters:

Name
Type
Description

_incentivesManager

address

The address of the IIncentivesManager implementation.


transferOwnership

function transferOwnership(address newOwner) external onlyOwner

Description:

Allows the current owner to transfer ownership of the Voter contract to a new address.

Input Parameters:

Name
Type
Description

newOwner

address

The address of the new contract owner.


reset

function reset(uint _tokenId) external

Description:

Resets all votes cast by a specific veNFT (_tokenId). It removes the NFT's weight from all pools it previously voted for, updates the total weight, withdraws the NFT's deposits from associated bribe contracts, and calls abstain on the VotingEscrow contract. Requires the caller to be the owner or approved operator of the NFT.

Input Parameters:

Name
Type
Description

_tokenId

uint

The ID of the veNFT whose votes should be reset.

Events Emitted:

Abstained(uint tokenId, int256 weight) for each pool the NFT was previously voting on.


poke

function poke(uint _tokenId) external

Description:

Refreshes the vote weights for a specific veNFT (_tokenId) based on its current voting power in the VotingEscrow contract, without changing the relative allocation percentages across the pools the NFT has already voted for. This is useful if the NFT's underlying lock has decayed or been extended, changing its voting power.

Input Parameters:

Name
Type
Description

_tokenId

uint

The ID of the veNFT whose vote weights should be refreshed ("poked").

Events Emitted:

Abstained (during the internal _reset), Voted (when re-applying weights).


vote

function vote(uint tokenId, address[] calldata _poolVote, int256[] calldata _weights) external

Description:

Allows a user to cast or update their votes using a specific veNFT (tokenId). The user provides a list of pool addresses (_poolVote) and corresponding relative weights (_weights). The contract calculates the actual voting power applied to each pool based on the NFT's total voting power and the provided relative weights. It resets any previous votes by the NFT before applying the new ones, updates total weights, and deposits the NFT's calculated weight into the corresponding bribe contracts. Requires the caller to be the owner or approved operator of the NFT.

Input Parameters:

Name
Type
Description

tokenId

uint

The ID of the veNFT being used to vote.

_poolVote

address[] calldata

An array of pool contract addresses to vote for.

_weights

int256[] calldata

An array of relative weights corresponding to each pool in _poolVote. Must have the same length.

Events Emitted:

Abstained (during the internal _reset), Voted.


createGauge

function createGauge(address _pool) external onlyOwner returns (address)

Description:

Allows the owner to create and register a new gauge and associated bribe contract for a given liquidity pool (_pool). It uses the configured gaugefactory and bribefactory, stores the mappings, adds the pool to the list, and approves the new gauge to spend the base reward token.

Input Parameters:

Name
Type
Description

_pool

address

The address of the liquidity pool token (or other identifier) for the gauge.

Return Value:

Type
Description

address

The address of the newly created gauge.

Events Emitted:

GaugeCreated(address indexed gauge, address creator, address indexed bribe, address indexed pool)


attachTokenToGauge

function attachTokenToGauge(uint tokenId, address account) external

Description:

Intended to be called by a gauge contract when a user stakes their veNFT (tokenId) directly into the gauge. It calls the attach function on the VotingEscrow contract to potentially link the NFT's voting power to the gauge's activity. Requires msg.sender to be a registered gauge.

Input Parameters:

Name
Type
Description

tokenId

uint

The ID of the veNFT being attached.

account

address

The address of the user attaching the NFT.

Events Emitted:

Attach(address indexed owner, address indexed gauge, uint tokenId)


emitDeposit

function emitDeposit(uint tokenId, address account, uint amount) external

Description:

Intended to be called by a gauge contract when a user deposits LP tokens into it, potentially associated with a veNFT (tokenId). This function purely emits an event for off-chain tracking. Requires msg.sender to be a registered gauge.

Input Parameters:

Name
Type
Description

tokenId

uint

The ID of the associated veNFT (can be 0).

account

address

The address of the user depositing LP tokens.

amount

uint

The amount of LP tokens deposited.

Events Emitted:

Deposit(address indexed lp, address indexed gauge, uint tokenId, uint amount)


detachTokenFromGauge

function detachTokenFromGauge(uint tokenId, address account) external

Description:

Intended to be called by a gauge contract when a user unstakes their veNFT (tokenId) from the gauge. It calls the detach function on the VotingEscrow contract. Requires msg.sender to be a registered gauge.

Input Parameters:

Name
Type
Description

tokenId

uint

The ID of the veNFT being detached.

account

address

The address of the user detaching the NFT.

Events Emitted:

Detach(address indexed owner, address indexed gauge, uint tokenId)


emitWithdraw

function emitWithdraw(uint tokenId, address account, uint amount) external

Description:

Intended to be called by a gauge contract when a user withdraws LP tokens from it, potentially associated with a veNFT (tokenId). This function purely emits an event for off-chain tracking. Requires msg.sender to be a registered gauge.

Input Parameters:

Name
Type
Description

tokenId

uint

The ID of the associated veNFT (can be 0).

account

address

The address of the user withdrawing LP tokens.

amount

uint

The amount of LP tokens withdrawn.

Events Emitted:

Withdraw(address indexed lp, address indexed gauge, uint tokenId, uint amount)


length

function length() external view returns (uint)

Description:

Returns the total number of pools (and corresponding gauges) registered in the Voter contract.

Return Value:

Type
Description

uint

The number of pools in the pools array.


notifyRewardAmount

function notifyRewardAmount(uint amount) external

Description:

Used to deposit the base reward token into the Voter contract for future distribution to gauges. It transfers the specified amount from the caller (msg.sender) to this contract and updates the global reward index based on the deposited amount and the current totalWeight of votes.

Input Parameters:

Name
Type
Description

amount

uint

The amount of base reward token being added for distribution.

Events Emitted:

NotifyReward(address indexed sender, address indexed reward, uint amount)


updateFor

function updateFor(address[] memory _gauges) external

Description:

Updates the reward accounting for a list of specified gauge addresses. This calculates the rewards accrued to each gauge since its last update based on its weight and the global reward index changes.

Input Parameters:

Name
Type
Description

_gauges

address[] memory

An array of gauge addresses to update.


updateForRange

function updateForRange(uint start, uint end) public

Description:

Updates the reward accounting for a range of gauges, specified by their index in the internal pools array.

Input Parameters:

Name
Type
Description

start

uint

The starting index (inclusive) in the pools array.

end

uint

The ending index (exclusive) in the pools array.


updateAll

function updateAll() external

Description:

Updates the reward accounting for all registered gauges by calling updateForRange for the entire pools array.


updateGauge

function updateGauge(address _gauge) external

Description:

Updates the reward accounting for a single specified gauge address.

Input Parameters:

Name
Type
Description

_gauge

address

The gauge address to update.


claimRewards

function claimRewards(address[] memory _gauges, address[][] memory _tokens) external

Description:

Allows a user (msg.sender) to claim their accumulated rewards directly from multiple gauge contracts. It iterates through the provided gauge addresses and calls the getReward function on each gauge, passing the user's address and a list of reward token addresses (_tokens) specific to that gauge.

Input Parameters:

Name
Type
Description

_gauges

address[] memory

An array of gauge addresses from which to claim rewards.

_tokens

address[][] memory

A nested array where _tokens[i] is an array of reward token addresses to claim from _gauges[i].


claimBribes

function claimBribes(address[] memory _bribes, address[][] memory _tokens, uint _tokenId) external

Description:

Allows a user to claim external bribe rewards associated with their vote cast using a specific veNFT (_tokenId). It iterates through the provided bribe contract addresses and calls getRewardForOwner on each, passing the NFT ID and the relevant token addresses for that bribe contract. Requires the caller to be the owner or approved operator of the NFT.

Input Parameters:

Name
Type
Description

_bribes

address[] memory

An array of bribe contract addresses from which to claim.

_tokens

address[][] memory

A nested array where _tokens[i] is an array of bribe token addresses to claim from _bribes[i].

_tokenId

uint

The ID of the veNFT whose votes earned the bribes.


claimFees

function claimFees(address[] memory _fees, address[][] memory _tokens, uint _tokenId) external

Description:

Allows a user to claim fee rewards associated with their vote cast using a specific veNFT (_tokenId).

Input Parameters:

Name
Type
Description

_fees

address[] memory

An array of fee/bribe contract addresses from which to claim.

_tokens

address[][] memory

A nested array where _tokens[i] is an array of fee token addresses to claim from _fees[i].

_tokenId

uint

The ID of the veNFT whose votes earned the fees.


distributeFees

function distributeFees(address[] memory _gauges) external

Description:

Triggers the fee distribution process within multiple specified gauge contracts by calling the claimFees function on each gauge. This likely causes the gauges to collect accrued trading fees from their associated liquidity pools and potentially transfer them to the corresponding bribe contracts.

Input Parameters:

Name
Type
Description

_gauges

address[] memory

An array of gauge addresses to trigger fee distribution for.


distribute (single gauge)

function distribute(address _gauge) public lock

Description:

Distributes the accumulated base reward tokens from this Voter contract to a specific gauge. It first updates the gauge's reward accounting (_updateFor), checks if there are claimable rewards, consults the IncentivesManager (if set), potentially checks against rewards already remaining in the gauge, and if conditions are met, transfers the calculated _claimable amount to the gauge via its notifyRewardAmount function. Uses a re-entrancy lock.

Input Parameters:

Name
Type
Description

_gauge

address

The address of the gauge to distribute rewards to.

Events Emitted:

DistributeReward(address indexed sender, address indexed gauge, uint amount)


distro / distribute (no args)

function distro() external
function distribute() external

Description:

Distributes the accumulated base reward tokens to all registered gauges by calling the internal distribute(start, finish) function for the entire range of pools. distro() is an alias for distribute().

Events Emitted: DistributeReward (for each gauge distribution performed internally).


distribute (range)

function distribute(uint start, uint finish) public

Description:

Distributes the accumulated base reward tokens to a range of gauges specified by their index in the pools array.

Input Parameters:

Name
Type
Description

start

uint

The starting index (inclusive) in the pools array.

finish

uint

The ending index (exclusive) in the pools array.

Events Emitted:

DistributeReward (for each gauge distribution performed internally).


distribute (gauge array)

function distribute(address[] memory _gauges) external

Description:

Distributes the accumulated base reward tokens to a specific list of gauges provided in the array.

Input Parameters:

Name
Type
Description

_gauges

address[] memory

An array of gauge addresses to distribute rewards to.

Events Emitted:

DistributeReward (for each gauge distribution performed internally).

PreviousVoteEscrowDistributionNextVoteEscrow

Last updated 2 months ago