# MaverickV2VotingEscrowFactory

**Inherits:** [IMaverickV2VotingEscrowFactory](https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-reward-contracts/interfaces/imaverickv2votingescrowfactory)

Factory to deploy veTokens. The resulting ve contracts are deployed using create2 and have deterministic addresses.

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

#### baseTokenParameter <a href="#basetokenparameter" id="basetokenparameter"></a>

This function retrieves the default base token used for creating new voting escrow contracts. This state variable is only used temporarily when a new veToken is deployed.

```solidity
IERC20 public baseTokenParameter;
```

#### isFactoryToken <a href="#isfactorytoken" id="isfactorytoken"></a>

This function checks whether a provided IMaverickV2VotingEscrow contract address was created by this factory.

```solidity
mapping(IMaverickV2VotingEscrow => bool) public isFactoryToken;
```

#### legacyVeMav <a href="#legacyvemav" id="legacyvemav"></a>

This function retrieves the address of the legacy Maverick V1 Voting Escrow (veMAV) token. The address will be zero for blockchains where this contract is deployed that do not have a legacy MAV contract deployed.

```solidity
IERC20 public immutable legacyVeMav;
```

#### \_allVotingEscrow <a href="#allvotingescrow" id="allvotingescrow"></a>

```solidity
IMaverickV2VotingEscrow[] private _allVotingEscrow;
```

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

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

```solidity
constructor(IERC20 legacyVeMav_);
```

#### createVotingEscrow <a href="#createvotingescrow" id="createvotingescrow"></a>

Create a ve token for an input base token.

Once the ve contract is created, it will call `name()` and `symbol()` on the `baseToken`. If those functions do not exist, the ve creation will revert.

```solidity
function createVotingEscrow(IERC20 baseToken) public returns (IMaverickV2VotingEscrow veToken);
```

**Parameters**

| Name        | Type     | Description                                                                       |
| ----------- | -------- | --------------------------------------------------------------------------------- |
| `baseToken` | `IERC20` | The address of the ERC-20 token to be used as the base token for the new veToken. |

**Returns**

| Name      | Type                      | Description                                                        |
| --------- | ------------------------- | ------------------------------------------------------------------ |
| `veToken` | `IMaverickV2VotingEscrow` | The address of the newly created IMaverickV2VotingEscrow contract. |

#### votingEscrows <a href="#votingescrows" id="votingescrows"></a>

This function retrieves a paginated list of existing Maverick V2 Voting Escrow (veToken) contracts within a specified index range.

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

**Parameters**

| Name         | Type      | Description                                           |
| ------------ | --------- | ----------------------------------------------------- |
| `startIndex` | `uint256` | The starting index for the desired range of veTokens. |
| `endIndex`   | `uint256` | The ending index for the desired range of veTokens.   |

**Returns**

| Name             | Type                        | Description                                                                                                       |
| ---------------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `returnElements` | `IMaverickV2VotingEscrow[]` | votingEscrows An array of IMaverickV2VotingEscrow addresses representing the veTokens within the specified range. |

#### votingEscrowsLength <a href="#votingescrowslength" id="votingescrowslength"></a>

This function retrieves the total number of deployed Maverick V2 Voting Escrow (veToken) contracts.

```solidity
function votingEscrowsLength() external view returns (uint256 count);
```

**Returns**

| Name    | Type      | Description                   |
| ------- | --------- | ----------------------------- |
| `count` | `uint256` | The total number of veTokens. |

#### votingEscrowAddress <a href="#votingescrowaddress" id="votingescrowaddress"></a>

This function retrieves the address of the existing Maverick V2 Voting Escrow (veToken) contract associated with a specific ERC20 base token.

```solidity
function votingEscrowAddress(IERC20 baseToken) public view returns (IMaverickV2VotingEscrow veToken);
```

**Parameters**

| Name        | Type     | Description                                                                     |
| ----------- | -------- | ------------------------------------------------------------------------------- |
| `baseToken` | `IERC20` | The address of the ERC-20 base token for which to retrieve the veToken address. |

**Returns**

| Name      | Type                      | Description                                                                                                             |
| --------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `veToken` | `IMaverickV2VotingEscrow` | The address of the IMaverickV2VotingEscrow contract associated with the base token, or the zero address if none exists. |

#### \_nameSymbolGetter <a href="#namesymbolgetter" id="namesymbolgetter"></a>

```solidity
function _nameSymbolGetter(IERC20 baseToken) internal view returns (string memory name, string memory symbol);
```

<br>
