# VotingReward

## Overview

The `VotingReward` contract used by `FeesVotingReward` and `BribeVotingReward` allows to distribute rewards to users, earned through voting for a pool.

## VotingReward Methods

### getReward

Claim the rewards earned by a voter for a given token.

```solidity
function getReward(
    address _user,
    address _token
) 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>_token</code></td><td>address</td><td>The token to claim rewards of.</td></tr></tbody></table>

### getReward

Claim the rewards earned by a voter for a given token.

```solidity
function getReward(
    address _user,
    address[] calldata _tokens
) 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>_tokens</code></td><td>address[] calldata</td><td>The array of tokens to claim rewards of.</td></tr></tbody></table>

### \_deposit

Deposit an amount into the rewards contract to earn future rewards.

{% hint style="warning" %}
Internal notation used as only callable internally by `Voter`.
{% endhint %}

```solidity
function _deposit(
    uint256 _amount,
    address _user
) 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>_amount</code></td><td>uint256</td><td>The amount deposited for the user.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user.</td></tr></tbody></table>

### \_withdraw

Withdraw an amount from the rewards contract associated to a voter.

{% hint style="warning" %}
Internal notation used as only callable internally by `Voter`.
{% endhint %}

```solidity
function _withdraw(
    uint256 _amount,
    address _user
) 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>_amount</code></td><td>uint256</td><td>The amount withdrawn for the user.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user.</td></tr></tbody></table>

## View Methods

### dao

Return the address of DAO.

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

### DURATION

Return the epoch duration constant (7 days).

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

### voter

Return the address of `Voter.sol`.

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

### poolId

Return the identifier of the pool this contrat is associated with.

```solidity
function poolId() external view returns (uint160)
```

### totalSupply

Return the total amount currently deposited via \_deposit().

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

### balanceOf

Return the current amount deposited by given user.

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

### tokenRewardsPerEpoch

Return the amount of tokens to reward depositors for a given epoch.

```solidity
function tokenRewardsPerEpoch(
    address _token,
    uint256 _epochStart
) external view returns (uint256)
```

### lastEarn

Return the most recent timestamp a user has claimed their rewards for given tokens.

```solidity
function lastEarn(
    address _token,
    address _user
) external view returns (uint256)
```

### rewards

Return the token address stored at the given index in the list of rewards token.

```solidity
function rewards(uint256 _index) external view returns (address)
```

### rewardsListLength

Return the number of rewards tokens.

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

### getAllRewards

Return the list of rewards tokens.

```solidity
function getAllRewards() external view returns (address[])
```

### isReward

Return wether a token is or has been an active reward token.

```solidity
function isReward(address _token) external view returns (bool)
```

### daoFee

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

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

### numCheckpoints

Return the number of checkpoints for each user address.

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

### supplyNumCheckpoints

Return the total number of checkpoints.

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

### getPriorBalanceIndex

Return the prior balance for an account as of a block number.

```solidity
function getPriorBalanceIndex(
    address _user,
    uint256 _timestamp
) external view returns (uint256);
```

<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.</td></tr><tr><td><code>_timestamp</code></td><td>uint256</td><td>The timestamp to get the balance at.</td></tr></tbody></table>

{% hint style="warning" %}
Block number must be a finalized block or else this function will revert to prevent misinformation.
{% endhint %}

### getPriorSupplyIndex

Return the prior index of supply staked by a given timestamp.

```solidity
function getPriorSupplyIndex(uint256 _timestamp) external view returns (uint256)
```

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_timestamp</code></td><td>uint256</td><td>The timestamp to get the index at.</td></tr></tbody></table>

{% hint style="warning" %}
Timestamp must be <= current timestamp
{% endhint %}

### earned

Return how much in rewards are earned for a specific token and voter.

<pre class="language-solidity"><code class="lang-solidity">function earned(
<strong>    address _token,
</strong><strong>    address _user
</strong><strong>) external view returns (uint256)
</strong></code></pre>

<table><thead><tr><th width="246.33333333333331">Input Parameter</th><th width="188">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>_token</code></td><td>address</td><td>The token to fetch rewards of.</td></tr><tr><td><code>_user</code></td><td>address</td><td>The address of the user to check.</td></tr></tbody></table>
