# MaverickV2RewardFactory

**Inherits:** [IMaverickV2RewardFactory](/technical-reference/maverick-v2/v2-contracts/maverick-v2-reward-contracts/interfaces/imaverickv2rewardfactory.md)

Reward contract factory that facilitates rewarding stakers in BoostedPositions.

### State Variables <a href="#state-variables" id="state-variables"></a>

#### boostedPositionFactory <a href="#boostedpositionfactory" id="boostedpositionfactory"></a>

This function retrieves the address of the MaverickV2BoostedPositionFactory contract.

```solidity
IMaverickV2BoostedPositionFactory public immutable boostedPositionFactory;
```

#### votingEscrowFactory <a href="#votingescrowfactory" id="votingescrowfactory"></a>

This function retrieves the address of the MaverickV2VotingEscrowFactory contract.

```solidity
IMaverickV2VotingEscrowFactory public immutable votingEscrowFactory;
```

#### isFactoryContract <a href="#isfactorycontract" id="isfactorycontract"></a>

This function checks if a provided IMaverickV2Reward contract is a valid contract created by this factory.

```solidity
mapping(IMaverickV2Reward => bool) public isFactoryContract;
```

#### \_rewardsForStakeToken <a href="#rewardsforstaketoken" id="rewardsforstaketoken"></a>

```solidity
mapping(IERC20 stakeToken => IMaverickV2Reward[]) private _rewardsForStakeToken;
```

#### \_allRewards <a href="#allrewards" id="allrewards"></a>

```solidity
IMaverickV2Reward[] private _allRewards;
```

#### \_boostedPositionRewards <a href="#boostedpositionrewards" id="boostedpositionrewards"></a>

```solidity
IMaverickV2Reward[] private _boostedPositionRewards;
```

#### \_nonBoostedPositionRewards <a href="#nonboostedpositionrewards" id="nonboostedpositionrewards"></a>

```solidity
IMaverickV2Reward[] private _nonBoostedPositionRewards;
```

### Functions <a href="#functions" id="functions"></a>

#### constructor <a href="#constructor" id="constructor"></a>

```solidity
constructor(
    IMaverickV2BoostedPositionFactory boostedPositionFactory_,
    IMaverickV2VotingEscrowFactory votingEscrowFactory_
);
```

#### createRewardsContract <a href="#createrewardscontract" id="createrewardscontract"></a>

This function creates a new MaverickV2Reward contract associated with a specific stake token contract and set of reward and voting escrow tokens.

```solidity
function createRewardsContract(
    IERC20 stakeToken,
    IERC20[] memory rewardTokens,
    IMaverickV2VotingEscrow[] memory veTokens
) public returns (IMaverickV2Reward rewardsContract);
```

**Parameters**

| Name           | Type                        | Description                                                                                               |
| -------------- | --------------------------- | --------------------------------------------------------------------------------------------------------- |
| `stakeToken`   | `IERC20`                    | Token to be staked in reward contract; e.g. a boosted position contract.                                  |
| `rewardTokens` | `IERC20[]`                  | An array of IERC20 token addresses representing the available reward tokens.                              |
| `veTokens`     | `IMaverickV2VotingEscrow[]` | An array of IMaverickV2VotingEscrow contract addresses representing the associated veTokens for boosting. |

**Returns**

| Name              | Type                | Description                                   |
| ----------------- | ------------------- | --------------------------------------------- |
| `rewardsContract` | `IMaverickV2Reward` | The newly created IMaverickV2Reward contract. |

#### rewardsForStakeToken <a href="#rewardsforstaketoken" id="rewardsforstaketoken"></a>

This function retrieves a list of all MaverickV2Reward contracts associated with a specific staking token contract within a specified range.

```solidity
function rewardsForStakeToken(IERC20 stakeToken, uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2Reward[] memory);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `stakeToken` | `IERC20`  | Lookup token.                               |
| `startIndex` | `uint256` | The starting index of the list to retrieve. |
| `endIndex`   | `uint256` | The ending index of the list to retrieve.   |

**Returns**

| Name     | Type                  | Description                                                                                                             |
| -------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `<none>` | `IMaverickV2Reward[]` | rewardsContract An array of IMaverickV2Reward contracts associated with the BoostedPosition within the specified range. |

#### rewards <a href="#rewards" id="rewards"></a>

This function retrieves a list of all MaverickV2Reward contracts within a specified range.

```solidity
function rewards(uint256 startIndex, uint256 endIndex) external view returns (IMaverickV2Reward[] memory);
```

**Parameters**

| Name         | Type      | Description                                 |
| ------------ | --------- | ------------------------------------------- |
| `startIndex` | `uint256` | The starting index of the list to retrieve. |
| `endIndex`   | `uint256` | The ending index of the list to retrieve.   |

**Returns**

| Name     | Type                  | Description                                                                         |
| -------- | --------------------- | ----------------------------------------------------------------------------------- |
| `<none>` | `IMaverickV2Reward[]` | rewardsContract An array of IMaverickV2Reward contracts within the specified range. |

#### boostedPositionRewards <a href="#boostedpositionrewards" id="boostedpositionrewards"></a>

```solidity
function boostedPositionRewards(uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2Reward[] memory);
```

#### nonBoostedPositionRewards <a href="#nonboostedpositionrewards" id="nonboostedpositionrewards"></a>

```solidity
function nonBoostedPositionRewards(uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2Reward[] memory);
```

#### \_checkRewards <a href="#checkrewards" id="checkrewards"></a>

```solidity
function _checkRewards(IERC20 rewardToken, IMaverickV2VotingEscrow veToken) internal view;
```

#### \_slice <a href="#slice" id="slice"></a>

```solidity
function _slice(IMaverickV2Reward[] storage _rewards, uint256 startIndex, uint256 endIndex)
    internal
    view
    returns (IMaverickV2Reward[] memory returnElements);
```

<br>


---

# 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://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-reward-contracts/maverickv2rewardfactory.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.
