# Voter

## Overview

The `Voter` contract allows to vote for the proportion of weekly emissions that go to each pool LPs, as well as and voting rewards creation. Votes can be cast once per epoch, and earn voters both bribes and fees from the pool they voted for.

{% hint style="info" %}
Given that votes for pools across all supported networks are managed on Ethereum, each pool is identified by a unique ID, in order to prevent address collusion, which may occur if two pools on different networks happen to share the same address.

Pool IDs can be obtained from `GovernanceRegistry`'s [`getPoolId()`](https://dev.spectra.finance/technical-reference/governanceregistry#getpoolid) function.
{% endhint %}

## Voter Methods

### vote

Handles the execution of command sequence.

```solidity
function vote(
    address _user,
    uint160[] calldata _poolVote,
    uint256[] calldata _weights
) external
```

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_user</code></td><td>address</td><td>The address of the user voting.</td></tr><tr><td><code>_poolVote</code></td><td>uint160[] calldata</td><td>The array of identifiers of pools that are voted for.</td></tr><tr><td><code>_weights</code></td><td>uint256[] calldata</td><td>The weights of pools.</td></tr></tbody></table>

### poke

Called by users to update voting balances in voting rewards contracts.

```solidity
function poke(
    address _user
) external
```

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_user</code></td><td>address</td><td>Address of the user whose balance are to be updated.</td></tr></tbody></table>

### batchVote

Called by approved address to vote for multiple users for pools. For each user, votes are distributed proportionally based on weights.

```solidity
function batchVote(
    address[] calldata _users,
    uint160[] calldata _poolVote,
    uint256[] calldata _weights
) external
```

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_users</code></td><td>address[] calldata</td><td>The addresses of the users voting.</td></tr><tr><td><code>_poolVote</code></td><td>uint160[] calldata</td><td>The array of identifiers of pools that are voted for.</td></tr><tr><td><code>_weights</code></td><td>uint256[] calldata</td><td>The weights of pools.</td></tr></tbody></table>

{% hint style="info" %}
Each user can only vote once per epoch.
{% endhint %}

{% hint style="info" %}
Users can only vote for registered pools with deployed voting rewards.
{% endhint %}

{% hint style="info" %}
Weights are distributed proportionally to the sum of the weights in the array.
{% endhint %}

{% hint style="warning" %}
Throws if length of \_poolVote and \_weights do not match.
{% endhint %}

### batchPoke

Called by approved address to update voting balances for multiple users in voting rewards contracts.

```solidity
function batchPoke(
    address[] calldata _users
) external
```

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_users</code></td><td>address[] calldata</td><td>The addresses of the users whose balance are to be updated.</td></tr></tbody></table>

### reset

Called by users to reset voting state.

```solidity
function reset(
    address _user
) external
```

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_user</code></td><td>address</td><td>Address of the user reseting.</td></tr></tbody></table>

{% hint style="info" %}
Can vote again after reset.
{% endhint %}

{% hint style="warning" %}
Cannot reset in the same epoch that you voted in.
{% endhint %}

### claimBribes

Bulk claim bribes for a given user address.

```solidity
claimBribes(
    address[] calldata _bribes,
    address[][] calldata _tokens,
    address _user
) external
```

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="213">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_bribes</code></td><td>address[] calldata</td><td>The array of BribeVotingReward contracts to collect from.</td></tr><tr><td><code>_tokens</code></td><td>address[][] calldata</td><td>The array of tokens that are used as bribes.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user to claim bribe rewards for.</td></tr></tbody></table>

### claimFees

Bulk claim fees for a given user address.

```solidity
claimFees(
    address[] calldata _fees,
    address[][] calldata _tokens,
    address _user
) external
```

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="214">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_fees</code></td><td>address[] calldata</td><td>The array of FeesVotingReward contracts to collect from.</td></tr><tr><td><code>_tokens</code></td><td>address[][] calldata</td><td>The array of tokens that are used as bribes.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user to claim fees rewards for.</td></tr></tbody></table>

### claimPoolsVotingRewards

Bulk claim bribes and fees for a given user address.

<pre class="language-solidity"><code class="lang-solidity">function claimPoolsVotingRewards(
    uint160[] calldata _poolIds,
<strong>    address[][] calldata _bribeTokens,
</strong>    address[][] calldata _feeTokens,
    address _user
) external
</code></pre>

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="214">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_poolIds</code></td><td>uint160[] calldata</td><td>The array of pool identifiers to collect associated bribes and fees from.</td></tr><tr><td><code>_bribeTokens</code></td><td>address[][] calldata</td><td>The array of list of tokens that are used as bribes for each pool.</td></tr><tr><td><code>_feeTokens</code></td><td>address[][] calldata</td><td>The array of list of tokens that are used as fees rewards for each pool.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user to claim bribe and fees rewards for.</td></tr></tbody></table>

### createVotingRewards

Create voting rewards for a pool (unpermissioned).

```solidity
function createVotingRewards(
    address _poolId
) external returns (address fees, address bribe)
```

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_poolId</code></td><td>uint160</td><td>The identifier of the pool.</td></tr></tbody></table>

<table><thead><tr><th width="191.33333333333331">Return Parameter</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>fees</code></td><td>address</td><td>The address of created FeesVotingReward.</td></tr><tr><td><code>bribe</code></td><td>address</td><td>The address of created BribeVotingReward.</td></tr></tbody></table>

{% hint style="warning" %}
Only one pair of voting rewards can be created for any pool. See `Voter`'s [`hasVotingRewards()`](#hasvotingrewards).
{% endhint %}

{% hint style="warning" %}
Pool needs to be registered in governance registry. See `GovernanceRegistry`'s [`isPoolRegistered()`](https://dev.spectra.finance/technical-reference/governanceregistry#ispoolregistered).
{% endhint %}

### setApprovalForAll

Give or take back approval for an operator to manage voting and rewards claiming on behalf of sender.

```solidity
function setApprovalForAll(
    address _operator,
    bool _approved
) external
```

<table><thead><tr><th width="190.33333333333331">Input Parameter</th><th width="190">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_operator</code></td><td>address</td><td>The address to set approval for.</td></tr><tr><td><code>_approved</code></td><td>bool</td><td>True to approve operator, false otherwise.</td></tr></tbody></table>

## View Methods

### dao

Return the address of DAO.

```solidity
function dao() external view returns (address)
```

### forwarder

Return the address of trusted forwarder.

```solidity
function forwarder() external view returns (address)
```

### ve

Return the address of the ve token that governs these contracts.

```solidity
function ve() external view returns (address)
```

### governanceRegistry

Return the address of GovernanceRegistry.

```solidity
function governanceRegistry() external view returns (address)
```

### totalWeight

Return the total voting weight.

```solidity
function totalWeight() external view returns (uint256)
```

### maxVotingNum

Return the max number of pools one voter can vote for at once.

```solidity
function maxVotingNum() external view returns (uint256)
```

### defaultFeesRewardsDaoFee

Return the default share of fees voting rewards to be sent to the DAO, in basis points.

```solidity
function defaultFeesRewardsDaoFee() external view returns (uint256)
```

### defaultBribeRewardsDaoFee

Return the default share of bribe voting rewards to be sent to the DAO, in basis points.

```solidity
function defaultBribeRewardsDaoFee() external view returns (uint256)
```

### poolIds

Return the pool identifier stored at the given index in the list of identifiers of pools supporting voting rewards.

```solidity
function poolIds(address _index) external view returns (uint160)
```

### length

Return the number of pools with associated voting rewards.

```solidity
function length() external view returns (uint256)
```

### getAllPoolIds

Return the list of all pool identifiers for pools with associated voting rewards.

```solidity
function getAllPoolIds() external view returns (uint160[])
```

### hasVotingRewards

Return wether voting rewards are deployed for a given pool.

```solidity
function hasVotingRewards(uint160 _poolId) external view returns (bool)
```

### poolToFees

Return the FeesVotingRewards contract associated with given pool.

<pre class="language-solidity"><code class="lang-solidity"><strong>function poolToFees(uint160 _poolId) external view returns (address)
</strong></code></pre>

### poolToBribe

Return the BribeVotingRewards contract associated with given pool.

```solidity
function poolToBribe(uint160 _poolId) external view returns (address)
```

### weights

Return the total voting weight for a given pool.

```solidity
function weights(uint160 _poolId) external view returns (uint256)
```

### votes

Return the voting weight attributed by a given user to a given pool.&#x20;

```solidity
function votes(address _user, uint160 _poolId) external view returns (uint256)
```

### usedWeights

Return the total used voting weight of a given user.

```solidity
function usedWeights(address _user) external view returns (uint256)
```

### lastVoted

Return the timestamp of last votefor a given user.

```solidity
function lastVoted(address _user) external view returns (uint256)
```

### isWhitelistedBribeToken

Return wether a token is whitelisted as a possible bribe reward.

```solidity
function isWhitelistedBribeToken(address token) external view returns (bool)
```

### isWhitelistedUser

Return wether a user is whitelisted to vote outside of voting periods.

```solidity
function isWhitelistedUser(address _user) external view returns (bool)
```

### isVoteAuthorized

Return wether voting authorized for a given pool.

```solidity
function isVoteAuthorized(uint160 _poolId) external view returns (bool)
```

### voted

Return wether a given user currently has a voting position.

```solidity
function voted(address _user) external view returns (bool)
```

### restricted

Return wether a given user is restricted from voting.

<pre class="language-solidity"><code class="lang-solidity"><strong>function restricted(address _user) external view returns (bool)
</strong></code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.spectra.finance/technical-reference/contract-functions/voter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
