# MaverickV2IncentiveMatcherFactory

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

IncentiveMatcherFactory creates IncentiveMatcher contracts that can be used to facilitate voting on incentive directing and external protocol incentive matching for a given veToken.

IncentiveMatcher contracts are deployed with create2 to deterministic addresses can computed prior to deployment.

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

#### incentiveMatcherParameters <a href="#incentivematcherparameters" id="incentivematcherparameters"></a>

```solidity
IncentiveMatcherParameters public incentiveMatcherParameters;
```

#### incentiveMatcherForVe <a href="#incentivematcherforve" id="incentivematcherforve"></a>

This function retrieves the address of the IncentiveMatcher contract associated with the current veToken.

```solidity
mapping(IMaverickV2VotingEscrow => IMaverickV2IncentiveMatcher) public override incentiveMatcherForVe;
```

#### isFactoryIncentiveMatcher <a href="#isfactoryincentivematcher" id="isfactoryincentivematcher"></a>

This function checks if the current contract is a factory contract for IncentiveMatchers.

```solidity
mapping(IMaverickV2IncentiveMatcher => bool) public isFactoryIncentiveMatcher;
```

#### \_allIncentiveMatcher <a href="#allincentivematcher" id="allincentivematcher"></a>

```solidity
IMaverickV2IncentiveMatcher[] private _allIncentiveMatcher;
```

#### veFactory <a href="#vefactory" id="vefactory"></a>

This function retrieves the address of the MaverickV2VotingEscrowFactory contract.

```solidity
IMaverickV2VotingEscrowFactory public immutable veFactory;
```

#### rewardFactory <a href="#rewardfactory" id="rewardfactory"></a>

This function retrieves the address of the MaverickV2RewardFactory contract.

```solidity
IMaverickV2RewardFactory public immutable rewardFactory;
```

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

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

```solidity
constructor(IMaverickV2VotingEscrowFactory _veFactory, IMaverickV2RewardFactory _rewardFactory);
```

#### createIncentiveMatcher <a href="#createincentivematcher" id="createincentivematcher"></a>

This function creates a new IncentiveMatcher contract for a given base token. The basetoken is required to have a deployed ve token before incentive matcher can be created. If no ve token exists, this function will revert. A ve token can be created with the ve token factory: `veFactory()`.

```solidity
function createIncentiveMatcher(IERC20 baseToken)
    public
    returns (IMaverickV2VotingEscrow veToken, IMaverickV2IncentiveMatcher incentiveMatcher);
```

**Parameters**

| Name        | Type     | Description                                  |
| ----------- | -------- | -------------------------------------------- |
| `baseToken` | `IERC20` | The base token for the new IncentiveMatcher. |

**Returns**

| Name               | Type                          | Description                                                 |
| ------------------ | ----------------------------- | ----------------------------------------------------------- |
| `veToken`          | `IMaverickV2VotingEscrow`     | The voting escrow token for the IncentiveMatcher.           |
| `incentiveMatcher` | `IMaverickV2IncentiveMatcher` | The address of the newly created IncentiveMatcher contract. |

#### incentiveMatchers <a href="#incentivematchers" id="incentivematchers"></a>

This function retrieves a list of existing IncentiveMatcher contracts.

```solidity
function incentiveMatchers(uint256 startIndex, uint256 endIndex)
    external
    view
    returns (IMaverickV2IncentiveMatcher[] memory returnElements);
```

**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                                                        |
| ---------------- | ------------------------------- | ------------------------------------------------------------------ |
| `returnElements` | `IMaverickV2IncentiveMatcher[]` | An array of IncentiveMatcher contracts within the specified range. |

#### incentiveMatchersLength <a href="#incentivematcherslength" id="incentivematcherslength"></a>

This function returns the total number of existing IncentiveMatcher contracts.

```solidity
function incentiveMatchersLength() external view returns (uint256);
```

#### incentiveMatcherAddress <a href="#incentivematcheraddress" id="incentivematcheraddress"></a>

This function retrieves the address of the IncentiveMatcher contract associated with a given veToken.

```solidity
function incentiveMatcherAddress(IMaverickV2VotingEscrow veToken)
    public
    view
    returns (IMaverickV2IncentiveMatcher incentiveMatcher);
```

**Parameters**

| Name      | Type                      | Description                                                                       |
| --------- | ------------------------- | --------------------------------------------------------------------------------- |
| `veToken` | `IMaverickV2VotingEscrow` | The voting escrow token for which to retrieve the corresponding IncentiveMatcher. |

**Returns**

| Name               | Type                          | Description                                                               |
| ------------------ | ----------------------------- | ------------------------------------------------------------------------- |
| `incentiveMatcher` | `IMaverickV2IncentiveMatcher` | The address of the IncentiveMatcher contract associated with the veToken. |

<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/maverickv2incentivematcherfactory.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.
